Skip to content

Commit 81a7281

Browse files
committed
update operations README.md files
1 parent f5ec5ba commit 81a7281

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

operations/automation-script/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Three arguments can be provided on the command line when calling the script:
1515

1616
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.
1717

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.
1919

2020
The script does the following steps:
2121
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:
3838
1. If any apply was done, the script goes into a second loop to wait for it to finish.
3939
1. When the apply is finished, the script downloads the apply log and the state files from before and after the apply.
4040

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-
4341
In addition to the loadAndRunWorkspace.sh script, this example includes the following files:
4442

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.
5245
1. [deleteWorkspace.sh](./deleteWorkspace.sh): a script that can be used to delete the workspace.
5346
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.
5447

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.
5655

5756
## Preparation
5857
Do the following before using this script:

operations/sentinel-policies-scripts/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ It also adds all of them to a specified policy set, using a **policy set ID** (w
3434
The script uses curl to interact with Terraform Enterprise via the TFE API. It performs the following steps:
3535

3636
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.
3939
1. It uses curl to invoke the [Upload a Policy API](https://www.terraform.io/docs/enterprise/api/policies.html#upload-a-policy).
4040
1. Finally, it prints out the number of policies found and imported.
4141

@@ -61,7 +61,7 @@ You will need to grab the Policy Set ID from the TFE GUI to use as a CLI argumen
6161
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
6262
1. Copy this data to your clipboard, working file, or directly terminal where you will run the `import_policies.sh` script
6363
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)
6565
1. Execute the script as follows:
6666

6767
`./import_policies.sh <polset-somenumber>` where \<polset-somenumber\> is your unique policy set ID

0 commit comments

Comments
 (0)