Skip to content

Commit

Permalink
CCL-2010:Initial code for dynatrace_privatelink_aws_allowlist (#26)
Browse files Browse the repository at this point in the history
* CCL-2010:Initial code for dynatrace_privatelink_aws_allowlist

* Add --fail and rename variables

---------

Co-authored-by: Chris Freeman <[email protected]>
Co-authored-by: Chris Freeman <[email protected]>
  • Loading branch information
3 people authored Feb 24, 2025
1 parent cb8b0e8 commit 1a19fb9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dynatrace_privatelink_aws_accounts_allowlist/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "terraform_data" "aws_allowlist" {
for_each = toset(var.aws_account_Ids)

provisioner "local-exec" {
when = create
command = <<EOF
curl -X PUT "https://$${DYNATRACE_ENVIRONMENT_ID}.live.dynatrace.com/api/config/v1/aws/privateLink/allowlistedAccounts/${each.key}" \
-H "accept: application/json; charset=utf-8" \
-H "Authorization: Api-Token $${DYNATRACE_API_TOKEN}" \
-H "Content-Type: application/json; charset=utf-8" -d "{\"id\":\"${each.key}\"}" \
--fail
EOF
}
provisioner "local-exec" {
when = destroy
command = <<EOF
curl -X DELETE "https://$${DYNATRACE_ENVIRONMENT_ID}.live.dynatrace.com/api/config/v1/aws/privateLink/allowlistedAccounts/${each.key}" \
-H "accept: application/json; charset=utf-8" \
-H "Authorization: Api-Token $${DYNATRACE_API_TOKEN}" \
--fail
EOF
}
}

5 changes: 5 additions & 0 deletions dynatrace_privatelink_aws_accounts_allowlist/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

variable "aws_accounts" {
description = "AWS accounts to add to the Dynatrace allow listDynatrace AWS Account IDs"
type = set(string)
}
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ module "ghes_dashboards" {
count = contains(keys(var.tenant_vars), "ghes_dashboard_hostname") ? 1 : 0
ghes_hostname = var.tenant_vars.ghes_dashboard_hostname
}

module "dynatrace_privatelink_aws_accounts_allowlist" {
source = "./dynatrace_privatelink_aws_accounts_allowlist"
aws_accounts = var.tenant_vars.privatelink_allowlist_aws_accounts
}

0 comments on commit 1a19fb9

Please sign in to comment.