Hi Team, I have a module that requires dual AWS providers. However, I can’t seem to pass it to my module and it keeps complaining the missing module
## Terraform required
from constructs import Construct
from cdktf import App, TerraformStack, S3Backend,TerraformHclModule
from cdktf_cdktf_provider_aws.provider import AwsProvider,AwsProviderAssumeRole
from imports.teamcity_server import TeamcityServer
from cdktf_cdktf_provider_aws.instance import Instance
class MyStack(TerraformStack):
def __init__(self, scope: Construct, ns: str):
super().__init__(scope, ns)
# Setup aws provider
# Version defined by requirements.txt package
aws_provider = AwsProvider(self,
"AWS",
region="us-west-2",
assume_role=[AwsProviderAssumeRole(
role_arn = "arn:aws:iam::xxx:role/teamcity-management",
session_name = "vpc"
)],
)
aws_r53_provider = AwsProvider(self,
"AWS_R53",
region="us-west-2",
alias = "r53_zones",
assume_role=[AwsProviderAssumeRole(
role_arn = "arn:aws:iam::xxx:role/route53-management",
session_name = "teamcity-server-management-r53"
)],
)
# S3 Remote Backend
S3Backend(self,
bucket="xx-terraform-state",
key="sample-infra/xx/xx/devops/terraform.tfstate",
encrypt=True,
region="us-west-2",
role_arn = "arn:aws:iam::xx:role/terraform",
dynamodb_table="xx-terraform-lock-table"
)
module = TeamcityServer(self, "teamcity-server",
providers= [aws_provider, aws_r53_provider],
teamcity_server_instance_type = "m7g.xlarge",
teamcity_server_instance_architecture = "arm64",
rds_postgres_version = "15.5",
rds_instance_type = "db.t4g.small",
rds_storage_type = "gp2",
rds_storage_size = 20, # min rds
rds_max_storage_size = 40
)
## App setup
app = App()
MyStack(app, "first_project")
## generate the required files in cdktf.out
app.synth()
Running cdktf deploy, it retuns the error
│ Error: Provider configuration not present
│
│ To work with
│ module.teamcity-server.aws_route53_record.teamcity_server_certificate_validation_record
│ its original provider configuration at
│ module.teamcity-server.provider["registry.terraform.io/hashicorp/aws"].r53_zones
│ is required, but it has been removed. This occurs when a provider
│ configuration is removed while objects created by that provider still exist
│ in the state. Re-add the provider configuration to destroy
│ module.teamcity-server.aws_route53_record.teamcity_server_certificate_validation_record,
│ after which you can remove the provider configuration again.
On my cdk.tf.json, I can see the following providers
"provider": {
"aws": [
{
"assume_role": [
{
"role_arn": "arn:aws:iam::xxx:role/teamcity-management",
"session_name": "vpc"
}
],
"region": "us-west-2"
},
{
"alias": "r53_zones",
"assume_role": [
{
"role_arn": "arn:aws:iam::xxx:role/route53-management",
"session_name": "teamcity-server-management-r53"
}
],
"region": "us-west-2"
}
]
},
Not sure what I did wrong here?