Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev env fix #1700

Merged
merged 12 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions aws/common/newrelic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ resource "newrelic_cloud_aws_link_account" "newrelic_cloud_integration_push" {
}

resource "newrelic_api_access_key" "newrelic_aws_access_key" {
count = var.enable_new_relic && var.env != "production" ? 1 : 0
account_id = var.new_relic_account_id
key_type = "USER"
name = "notify_tf_provider"
notes = "Used by Notify Terraform Code to create New Relic Resources"
count = var.enable_new_relic && var.env != "production" ? 1 : 0
account_id = var.new_relic_account_id
key_type = var.env == "staging" ? "USER" : "INGEST"
ingest_type = var.env == "staging" ? null : "LICENSE"
name = var.env == "staging" ? "notify_tf_provider" : "notify_tf_provider_${var.env}"
notes = "Used by Notify Terraform Code to create New Relic Resources"
}

resource "aws_iam_role" "firehose_newrelic_role" {
Expand All @@ -119,8 +120,15 @@ EOF
resource "random_string" "s3-bucket-name" {
count = var.enable_new_relic && var.env != "production" ? 1 : 0
length = 8
special = true
upper = true
special = false
upper = false
lifecycle {
ignore_changes = [
length,
upper,
special,
]
}
}

resource "aws_s3_bucket" "newrelic_aws_bucket" {
Expand Down
42 changes: 42 additions & 0 deletions env/staging/common/.terraform.lock.hcl

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

2 changes: 1 addition & 1 deletion env/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs = merge(
elb_account_ids = {
"${local.config_inputs.region}" = "${local.secret_inputs.elb_account_id}"
}
cbs_satellite_bucket_name = "cbs-satellite-${local.secret_inputs.account_id}"
cbs_satellite_bucket_name = local.config_inputs.env != "dev" ? "cbs-satellite-${local.secret_inputs.account_id}" : "cbs-satellite-notification-dev"
}
)

Expand Down
10 changes: 9 additions & 1 deletion scripts/deleteEnvironment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ terragrunt destroy -var-file ../$ENVIRONMENT.tfvars --terragrunt-non-interactive
popd
echo "Done."

# Delete Cloud Based Sensor Bucket
# Delete Cloud Based Sensor Bucket and New Relic resources
echo "Deleting Cloud Based Sensor S3 Bucket..."
pushd ../env/$ENVIRONMENT/common
terragrunt destroy -var-file ../$ENVIRONMENT.tfvars --target module.cbs_logs_bucket --terragrunt-non-interactive -auto-approve
echo "Done."
echo "Deleting new relic resources..."
terragrunt destroy -var-file ../$ENVIRONMENT.tfvars --target 'newrelic_cloud_aws_link_account.newrelic_cloud_integration_push[0]' --terragrunt-non-interactive -auto-approve
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add a comment here about deleting new relic resources similar to how you have for other resources

terragrunt destroy -var-file ../$ENVIRONMENT.tfvars --target 'newrelic_api_access_key.newrelic_aws_access_key[0]' --terragrunt-non-interactive -auto-approve
terragrunt destroy -var-file ../$ENVIRONMENT.tfvars --target 'newrelic_cloud_aws_link_account.newrelic_cloud_integration_pull[0]' --terragrunt-non-interactive -auto-approve
popd
echo "Done."


pip install boto3

# AWS Nuke chokes on large S3 Buckets, Deleting them manually
Expand Down Expand Up @@ -118,6 +124,8 @@ aws events delete-rule --name weeklyBudgetSpend
aws events remove-targets --rule google_cidr_testing --ids $(aws events list-targets-by-rule --rule google_cidr_testing --query 'Targets[].Id' --output text)
aws events delete-rule --name google_cidr_testing

aws sesv2 delete-email-identity --email-identity dev.notification.cdssandbox.xyz

AWS_REGION=us-east-1 aws ses set-active-receipt-rule-set
AWS_REGION=us-east-1 aws ses delete-receipt-rule-set --rule-set-name main

Expand Down
Loading