Open xposix opened 2 years ago
In case you want to create two aws_db_instance_role_association using the s3Import and s3Export feature it's even more drastically failing. The first one is failing like @xposix describes with:
│ Error: error associating RDS DB Instance (arn:aws:rds:eu-central-1:xxxxxxxx:db:test) IAM Role (arn:aws:iam::xxxxxx:role/s3-import-role): InvalidDBInstanceState: The status for the test DB instance is modifying. The DB instance is not available for s3Import feature.
│ status code: 400, request id: 53724b88-827a-4302-850e-4b14aaf83391
│
│ with aws_db_instance_role_association.rds_import,
│ on rds.tf line 41, in resource "aws_db_instance_role_association" "rds_import":
│ 41: resource "aws_db_instance_role_association" "rds_import" {
│
and the second fails with
│ Error: error waiting for RDS DB Instance (arn:aws:rds:eu-central-1:xxxxxxx:db:test) IAM Role (arn:aws:iam::xxxxxx:role/s3-export-role) association: couldn't find resource (21 retries)
│
│ with aws_db_instance_role_association.rds_export,
│ on rds.tf line 50, in resource "aws_db_instance_role_association" "rds_export":
│ 50: resource "aws_db_instance_role_association" "rds_export" {
│
This happening is on
Terraform v1.2.5 on darwin_arm64
provider registry.terraform.io/hashicorp/aws v4.25.0
Same code as @xposix plus
resource "aws_db_instance_role_association" "rds_export" {
depends_on = [
aws_iam_role_policy.rds_s3_bucket_export_policy
]
db_instance_identifier = module.postgresql_test.db_instance_arn
feature_name = "s3Export"
role_arn = aws_iam_role.rds_export.arn
}
This behavior is also happening for us when trying to associate roles (first s3-import then s3-export) to RDS Aurora Cluster (Serverless V2) with "aws_rds_cluster_role_association" resource. In the first attempt, it's able to add the first role (s3-import) but after then it's failing with:
Error: error creating RDS DB Cluster (XXX) IAM Role (arn:aws:iam::***:role/s3-export-role) Association: InvalidDBClusterStateFault: DB Cluster XXX is not available for IAM role association, disassociation, or updates for ARN: arn:aws:iam::***:role/s3-export-role. Wait for a moment and try again.
status code: 400, request id: xxx
on dbs.tf line 100, in resource "aws_rds_cluster_role_association" "test_export_role_association":
100: resource "aws_rds_cluster_role_association" "test_export_role_association" {
When we try to rerun the workflow, it's failing with (even if it was able to create and attach the s3-import role to the DB):
Error: DBClusterRoleNotFound: Role ARN arn:aws:iam::***:role/s3-import-role cannot be found for DB Cluster: XXX. Verify your role ARN and try again. You might need to include the feature-name parameter.
status code: 404, request id: xxx
on .terraform/modules/db/main.tf line 100, in resource "aws_rds_cluster" "standalone_regional":
100: resource "aws_rds_cluster" "standalone_regional" {
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v1.2.2 on darwin_arm64
Affected Resource(s)
Terraform Configuration Files
Debug Output
First
terraform apply
All the following
terraform apply
Expected Behavior
It should wait for the RDS instance to finish modifying and perform the required changes on it.
Actual Behavior
It tries to associate the role to the instance when its on
modifying
status and it fails. Then the user needs to retry to make it work.