Skip to content

Commit

Permalink
Release 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelStancik committed May 25, 2021
1 parent a7a8992 commit 1a0691c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 60 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This could be used by `Azure/appservice-settings@v1` action.

### `terraform`

The Hashicorp Terraform `tfvars` structure as `portal_app_settings_secrets` object.
The Hashicorp Terraform `tfvars.json` structure as `portal_app_settings_secrets` object.
This could be used by `hashicorp/[email protected]` action.

## Example usage
Expand Down Expand Up @@ -72,22 +72,22 @@ This could be used by `hashicorp/[email protected]` action.
- name: Set the ENV as tfvars
working-directory: terraform
run: |
echo $terraform_var > ./terraform.tfvars
echo $terraform_var > ./terraform.tfvars.json
env:
terraform_var: ${{ steps.aenv.outputs.terraform}}

```

The structure of variable.tf is:
```yaml
variable "portal_app_settings" {
variable "web_app_settings" {
type = map(map(string))
default = { "eun" = { "Hello" = "World" } }
sensitive = true
}
```

After deploy do not forget to remove the `terraform.tfvars` file for security reasons:
After deploy do not forget to remove the `terraform.tfvars.json` file for security reasons:
```yaml
# Create/Destroy infrastructure
- name: Create/Destroy infrastructure
Expand All @@ -96,18 +96,23 @@ After deploy do not forget to remove the `terraform.tfvars` file for security re
terraform init -input=false
terraform plan -out=tfplan -input=false
terraform apply -input=false tfplan
rm ./terraform.tfvars
rm ./terraform.tfvars.json
rm ./tfplan
```
The structure:
```yaml
web_app_settings = {
WEBSITES_PORT = "3000"
```json
{
"web_app_settings": {
"frontend": {
"WEBSITES_PORT": "3000",
"WEBSITES_URL": "http://localhost"
}
}
}
```
Assigning in Terraform:
```yaml
app_settings = var.web_app_settings
app_settings = var.web_app_settings[frontend]
```
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ outputs:
json:
description: 'The environment parameters in json for AppService config'
terraform:
description: 'The environment parameters as terraform secrets'
description: 'The environment parameters as terraform secrets in JSON format'
branding:
icon: 'download-cloud'
color: 'blue'
Expand Down
29 changes: 6 additions & 23 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "enhanced-env-azure-vault-action",
"version": "1.1.2",
"version": "1.1.3",
"description": "This action gets secrets from Azure Vault as ENV parameters for specific environment and type.",
"main": "index.js",
"scripts": {
Expand Down
31 changes: 6 additions & 25 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ const preparation = async (proposedEnvironment: string, proposedType: string ) =
terraformParameters.map( secretObject => {
if (secretObject.enabled && secretObject.environment === prefix && secretObject.tags.type !== undefined) {

core.setSecret(secretObject.value);
//core.setSecret(secretObject.value);
secretObject.value = (secretObject.value).replace(/\\/g, "\\\\");

if (secretObject.tags.type === 'frontend') tfvars_frontend.push(` "${secretObject.name}"="${secretObject.value}"\
`);
if (secretObject.tags.type === 'backend') tfvars_backend.push(` "${secretObject.name}"="${secretObject.value}"\
`);
if (secretObject.tags.type === 'frontend') tfvars_frontend.push(` "${secretObject.name}":"${secretObject.value}" `);
if (secretObject.tags.type === 'backend') tfvars_backend.push(` "${secretObject.name}":"${secretObject.value}" `);

}

Expand All @@ -71,27 +69,10 @@ const preparation = async (proposedEnvironment: string, proposedType: string ) =

const prepareTfVars = (frontend: string[], backend: string[]) => {

frontend.toString = function() {
return this.join(`\
`);
};

backend.toString = function() {
return this.join(`
`);
};

let return_object = `web_app_settings = {\
let return_object = `{ "web_app_settings": {\
`;
return_object = return_object.concat(`\
frontend = {\
${frontend}\
}, `);
return_object = return_object.concat(`\
backend = {\
${backend} \
} \
}`);
return_object = return_object.concat(` "frontend": { ${frontend} }, `);
return_object = return_object.concat(` "backend": { ${backend} } } }`);
return return_object;
}

Expand Down

0 comments on commit 1a0691c

Please sign in to comment.