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

Single CloudWatch logging role for API Gateways #89

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

cvangerpen
Copy link
Contributor

@cvangerpen cvangerpen commented Jan 29, 2025

API Gateway's CloudWatch logging role is account- and region-specific. This moves that role's creation to a single place rather than in both the cirrus and stac-server module as that leads to constant state drift.

Related issue(s)

  • N/A

Proposed Changes

  1. Remove the aws_api_gateway_account Terraform resource from the stac-server and cirrus module since having multiple instances will result in Terraform consistently switching between the two.
  2. Create a single aws_api_gateway_account Terraform resource as part of the base_infra module such that all modules implementing API Gateways can rely on logging permissions being handled once elsewhere.

Testing

This change was validated by the following observations:

Without this change, every terraform apply would produce the following state difference (switching between stac-server and cirrus roles):

# module.filmdrop.module.cirrus[0].module.cirrus.module.builtin_functions.aws_api_gateway_account.cirrus_api_gateway_cw_role will be updated in-place
~ resource "aws_api_gateway_account" "cirrus_api_gateway_cw_role" {
    ~ api_key_version     = "4" -> (known after apply)
    ~ cloudwatch_role_arn = "arn:aws:iam::123456789012:role/fd-example-dev-stac-server-us-west-2" -> "arn:aws:iam::123456789012:role/fd-kodiak-dev-cirrus-us-west-2"
    ~ features            = [
        - "UsagePlans",
    ] -> (known after apply)
    id                  = "api-gateway-account"
    ~ throttle_settings   = [
        - {
            - burst_limit = 5000
            - rate_limit  = 10000
        },
    ] -> (known after apply)
}

Plan: 0 to add, 1 to change, 0 to destroy.

After applying this commit and redeploying, Terraform correctly reports that no resources have changed for consecutive apply's.

Checklist

  • I have deployed and validated this change
  • Changelog
    • I have added my changes to the changelog
    • No changelog entry is necessary
  • README migration
    • I have added any migration steps to the Readme
    • No migration is necessary

API Gateway's CloudWatch logging role is account- and region-specific. This
moves that role's creation to a single place rather than in both the cirrus
and stac-server module as that leads to constant state drift.
@cvangerpen cvangerpen merged commit 3ae1b4f into main Jan 31, 2025
4 checks passed
@cvangerpen cvangerpen deleted the cvg/single-api-gateway-account-resource branch January 31, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants