hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.6k stars 8.99k forks source link

[Bug]: aws_cognito_identity_provider errors after AWS rotated encryption certificate #36912

Open KevinGimbel opened 2 months ago

KevinGimbel commented 2 months ago

Terraform Core Version

1.5.7

AWS Provider Version

5.45.0

Affected Resource(s)

Expected Behavior

A new Encryption Certificate from AWS should be accepted and added to the terraform state and/or ignored during updates.

Actual Behavior

Terraform cannot run through, showing the issue provided below. It's impossible to execute the terraform stack unless a temporary workaround is used (ignoring changes to the certificates)

lifecycle {
  ignore_changes = [provider_details["ActiveEncryptionCertificate"]]
}

Relevant Error/Panic Output Snippet

Error: updating Cognito Identity Provider (eu-central-1_XXX:XXX): InvalidParameterException: Signing certificates are expired

Terraform Configuration Files

This is a minimal example with the relevant parts, replacing all sensitive data with XXX, including our temporary fix (lifecycle rule).

terraform {
  required_version = ">= 0.15"
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

locals { 
  settings_cognito_provider_metadataurl_path = "federationmetadata/2007-06/federationmetadata.xml?appid=XXX"
  settings_cognito_provider_metadataurl_prefix = "https://login.microsoftonline.com/XXX"
}

resource "aws_cognito_identity_provider" "my_provider" {
  user_pool_id  = "xxx"
  provider_name = "xxx"
  provider_type = "SAML"

  provider_details = {
    MetadataURL           = "${local.settings_cognito_provider_metadataurl_prefix}/${local.settings_cognito_provider_metadataurl_path}"
    SLORedirectBindingURI = "${local.settings_cognito_provider_metadataurl_prefix}/saml2"
    SSORedirectBindingURI = "${local.settings_cognito_provider_metadataurl_prefix}/saml2"
    IDPSignout            = true
  }

  attribute_mapping = {
    email       = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
    given_name  = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"
    family_name = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surename"
  }

  lifecycle {
    ignore_changes = [provider_details["ActiveEncryptionCertificate"]]
  }
}

Steps to Reproduce

  1. Have AWS cognito linked to SAML provider
  2. AWS rotates certificates
  3. Terraform doesn't pick-up the new certificates

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Would you like to implement a fix?

None

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue