Skip to content

Commit 577fe3a

Browse files
committed
changed 150 limit to 100
1 parent 0c9c321 commit 577fe3a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

operations/sentinel-policies-scripts/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Before using these scripts, you need to export a valid TFE API token with the co
66
Before running these scripts, you must export or set the TFE ORG environment variable with the command `export TFE_ORG=<your_organization>` where \<your_organization\> is the target name of the organization containing the Sentinel policies you want to manage.
77

88
## Exporting Policies
9-
The export_policies.sh script exports all the policies from a TFE organization to the directory in which you run the script. It currently is limited to exporting 150 policies since it does not handle multiple pages from the List Policies API that retrieves them.
9+
The export_policies.sh script exports all the policies from a TFE organization to the directory in which you run the script. It currently is limited to exporting 100 policies since it does not handle multiple pages from the List Policies API that retrieves them.
1010

1111
The script uses curl to interact with Terraform Enterprise via the TFE API. It performs the following steps:
1212

13-
1. It uses curl to invoke the [List Policies API](https://www.terraform.io/docs/enterprise/api/policies.html#list-policies) against the organization specified in the organization variable. It sets the page[size] parameter to the maximum value of 150 policies.
13+
1. It uses curl to invoke the [List Policies API](https://www.terraform.io/docs/enterprise/api/policies.html#list-policies) against the organization specified in the organization variable. It sets the page[size] parameter to the maximum value of 100 policies.
1414
1. It extracts the policy IDs, names, enforcement modes, and code download links from the JSON returned by that API into arrays.
1515
1. It iterates across all the arrays simultaneously, doing the following:
1616
1. It retrieves the policy code from the code download link.
@@ -36,4 +36,4 @@ The script uses curl to interact with Terraform Enterprise via the TFE API. It p
3636
## Deleting Policies
3737
The delete_policies.sh script deletes all policies from a TFE organization. It uses curl to invoke the [List Policies API](https://www.terraform.io/docs/enterprise/api/policies.html#list-policies) to retrieve all Sentinel policies. It then iterates through these and invokes the [Delete a Policy API](https://www.terraform.io/docs/enterprise/api/policies.html#delete-a-policy) to delete them one at a time. It also prints out the ID of each deleted policy and finally gives a count of how many were deleted.
3838

39-
Currently, it will only delete 150 policies at a time since that is the largest value that we can set the page[size] parameter to. But if you need to delete more policies, just run the delete_policies.sh script again until you have deleted all of them.
39+
Currently, it will only delete 100 policies at a time since that is the largest value that we can set the page[size] parameter to. But if you need to delete more policies, just run the delete_policies.sh script again until you have deleted all of them.

operations/sentinel-policies-scripts/delete_policies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ organization="$TFE_ORG"
1515
echo "Using address: $address"
1616
echo "Using organization: $organization"
1717

18-
# Retrieve list of all policies in the organization (up to 150)
19-
policy_list_result=$(curl --header "Authorization: Bearer $TFE_TOKEN" "https://${address}/api/v2/organizations/${organization}/policies?page%5Bsize%5D=150")
18+
# Retrieve list of all policies in the organization (up to 100)
19+
policy_list_result=$(curl --header "Authorization: Bearer $TFE_TOKEN" "https://${address}/api/v2/organizations/${organization}/policies?page%5Bsize%5D=100")
2020
#echo $policy_list_result | jq
2121

2222
# Extract policy IDs

operations/sentinel-policies-scripts/export_policies.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ organization="$TFE_ORG"
1515
echo "Using address: $address"
1616
echo "Using organization: $organization"
1717

18-
# Retrieve list of all policies in the organization (up to 150)
19-
policy_list_result=$(curl --header "Authorization: Bearer $TFE_TOKEN" "https://${address}/api/v2/organizations/${organization}/policies?page%5Bsize%5D=150")
20-
#echo $policy_list_result | jq
18+
# Retrieve list of all policies in the organization (up to 100)
19+
policy_list_result=$(curl --header "Authorization: Bearer $TFE_TOKEN" "https://${address}/api/v2/organizations/${organization}/policies?page%5Bsize%5D=100")
20+
# echo $policy_list_result | jq
2121

2222
# Extract policy IDs
2323
policy_ids_list=($(echo $policy_list_result | jq -r '.data[].id'))

0 commit comments

Comments
 (0)