You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: operations/automation-script/README.md
+10-11Lines changed: 10 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Three arguments can be provided on the command line when calling the script:
15
15
16
16
If you only want to set override to "yes" without passing values for the first two arguments, please use `./loadAndRunWorkspace.sh "" "" yes` to run the script.
17
17
18
-
The script uses several json templates which must be placed in the same directory as the script itself.
18
+
The script uses several json templates which are written out to the file system and then deleted.
19
19
20
20
The script does the following steps:
21
21
1. Clones a git repository containing Terraform configuration code or uses the code in the config directory if no git URL was provided.
@@ -38,21 +38,20 @@ The script does the following steps:
38
38
1. If any apply was done, the script goes into a second loop to wait for it to finish.
39
39
1. When the apply is finished, the script downloads the apply log and the state files from before and after the apply.
40
40
41
-
*Note* that some json template files are included from which other json files are generated so that they can be passed to the curl commands.
42
-
43
41
In addition to the loadAndRunWorkspace.sh script, this example includes the following files:
44
42
45
-
1.[config/main.tf](./config/main.tf): the file with some Terraform code that says "Hello" to the person whose name is given and generates a random number. This is used if no git URL is provided to the script.
46
-
1.[workspace.template.json](./workspace.template.json) which is used to generate workspace.json which is used when creating the workspace. If you wish to add or modify the API commands that are included in _@workspace.json_ payload, add them to _workspace.template.json_ and be sure to check the Terraform Enterprise API [syntax](https://www.terraform.io/docs/enterprise/api/workspaces.html#update-a-workspace). Update or modify `"terraform-version": "0.11.14"` within _workspace.template.json_ to set a specific workspace version of Terraform OSS binary.
47
-
1.[configversion.json](./configversion.json) which is used to generate a new configuration version.
48
-
1.[variable.template.json](./variable.template.json) which is used to generate variable.json which is used when creating a variable called "name" in the workspace.
49
-
1.[run.template.json](./run.template.json) which is used to generate run.json which is used when triggering a run against the workspace.
50
-
1.[apply.json](./apply.json) which is used when doing the apply against the workspace.
51
-
1. variables.csv which contains the variables that are uploaded to the workspace if no file with the same name is found in the root directory of the cloned repository. The columns are key, value, category, hcl, and sensitive with the last two corresponding to the hcl and sensitive checkboxes of TFE variables.
43
+
1.[config/main.tf](./config/main.tf) which is a file with some Terraform code that says "Hello" to the person whose name is given and generates a random number. This is used if no git URL is provided to the script.
44
+
1.[variables.csv](./variables.csv) which contains the variables that are uploaded to the workspace if no file with the same name is found in the root directory of the cloned repository. The columns are key, value, category, hcl, and sensitive with the last two corresponding to the hcl and sensitive checkboxes of TFE variables. This should be in the same directory as the script unless you include a file with the same name in your git repository.
52
45
1.[deleteWorkspace.sh](./deleteWorkspace.sh): a script that can be used to delete the workspace.
53
46
1.[restrict-name-variable.sentinel](./restrict-name-variable.sentinel): a Sentinel policy you can add to your TFE organization in order to see how the script can check Sentinel policies and even override soft-mandatory failures.
54
47
55
-
*Note* that the json templates file need to be in the same directory as the script itself. The variables.csv file should also be in the same directory as the script unless you include a file with the same name in your git repository.
48
+
The following files are embedded inside the script:
49
+
50
+
1.**workspace.template.json** which is used to generate _workspace.json_ which is used when creating the workspace. If you wish to add or modify the settings that are included in the _@workspace.json_ payload, add them to _workspace.template.json_ inside the script and be sure to check the Terraform Enterprise API [syntax](https://www.terraform.io/docs/enterprise/api/workspaces.html#update-a-workspace). Update or modify `"terraform-version": "0.11.14"` within _workspace.template.json_ to set a specific workspace version of the Terraform OSS binary.
51
+
1.**configversion.json** which is used to generate a new configuration version.
52
+
1.**variable.template.json** which is used to generate _variable.json_ which is used when creating a variable called "name" in the workspace.
53
+
1.**run.template.json** which is used to generate _run.json_ which is used when triggering a run against the workspace.
54
+
1.**apply.json** which is used when doing the apply against the workspace.
Copy file name to clipboardExpand all lines: operations/sentinel-policies-scripts/README.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,8 @@ It also adds all of them to a specified policy set, using a **policy set ID** (w
34
34
The script uses curl to interact with Terraform Enterprise via the TFE API. It performs the following steps:
35
35
36
36
1. It iterates across all files in the current directory with the `*.sentinel` extension.
37
-
1. For each file, it generates a file create-policy.json from the template create-policy.template.json, substituting the name of the policy and the file name and setting a description based on the name.
38
-
1. It uses curl to invoke the [Create a Policy API](https://www.terraform.io/docs/enterprise/api/policies.html#create-a-policy), passing the generated create-policy.json file in the --data argument of the curl command.
37
+
1. For each file, it generates a file _create-policy.json_ from the template _create-policy.template.json_ (which is embedded in the script), substituting the name of the policy and the file name and setting a description based on the name.
38
+
1. It uses curl to invoke the [Create a Policy API](https://www.terraform.io/docs/enterprise/api/policies.html#create-a-policy), passing the generated _create-policy.json_ file in the --data argument of the curl command.
39
39
1. It uses curl to invoke the [Upload a Policy API](https://www.terraform.io/docs/enterprise/api/policies.html#upload-a-policy).
40
40
1. Finally, it prints out the number of policies found and imported.
41
41
@@ -61,7 +61,7 @@ You will need to grab the Policy Set ID from the TFE GUI to use as a CLI argumen
61
61
1. The programmatic _Policy Set ID_ required for this script is contained within the URL immediately after `/policy-sets/` for example: https://app.terraform.io/app/jray-hashi/settings/policy-sets/**polset-6YVMugX6VX3FG1Zu**/edit
62
62
1. Copy this data to your clipboard, working file, or directly terminal where you will run the `import_policies.sh` script
63
63
1. Create the desired Sentinel policies files and copy them into the directory where the script will be executed. Be sure they have a `*.sentinel` extension
64
-
1.Open `create-policy.template.json` and modify the value of `"mode":` to `advisory`, `soft-mandatory`, or `hard-mandatory` for the desired [enforcement type](https://www.terraform.io/docs/enterprise/api/policies.html#request-body)
64
+
1.Edit the embedded _create-policy.template.json_ file inside _import_policies.sh_ and modify the value of `"mode":` to `advisory`, `soft-mandatory`, or `hard-mandatory` for the desired [enforcement type](https://www.terraform.io/docs/enterprise/api/policies.html#request-body)
65
65
1. Execute the script as follows:
66
66
67
67
`./import_policies.sh <polset-somenumber>` where \<polset-somenumber\> is your unique policy set ID
0 commit comments