Skip to content
New issue

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

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

Already on GitHub? # to your account

(aws-certificatemanager): Ref intrinsic function should be used to implement attrId in the generated CfnCertificate construct instead of GetAtt #30650

Closed
moelasmar opened this issue Jun 24, 2024 · 3 comments
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@moelasmar
Copy link
Contributor

Describe the bug

In the generated CfnCertificate L1 construct, GetAtt intrinsic function is used to implement the attrId property, althoug as per CFN Docs, there is no support for GetAtt for this resource see here

this.attrId = cdk.Token.asString(this.getAtt("Id", cdk.ResolutionTypeHint.STRING));

Expected Behavior

I can use attrId without getting an error.

Current Behavior

when I use cfnCertificate.attrId in my CDK implementation, and then try to deploy I got the following exception

Deployment XXXXX failed because Couldn't call cloudformation for target XXXXXX because of a validation error. The error was Template error: resource DNSCertificate does not support attribute type Id in Fn::GetAtt (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; 

Reproduction Steps

const vpc = new Vpc(this, 'VPC', {
	cidr: '10.0.0.0/16',
	enableDnsHostnames: true,
	enableDnsSupport: true,
	maxAzs: props.maxAZs,
	defaultInstanceTenancy: DefaultInstanceTenancy.DEFAULT,
	subnetConfiguration: [
		{
			name: 'public-subnet-1',
			subnetType: SubnetType.PUBLIC,
			cidrMask: 20
		}
	]
 });

const securityGroup = new SecurityGroup(this, 'SecurityGroup', {
	vpc: vpc
 });

this.loadBalancer = new ApplicationLoadBalancer(this, 'LB', {
	vpc: vpc,
	securityGroup: securityGroup,
	internetFacing: true
});

const cfnCertificate = new CfnCertificate(this, 'DNSCertificate', {
	domainName: domainName,
	validationMethod: 'DNS',
	domainValidationOptions: [
		{
			domainName: domainName,
			hostedZoneId: hostedZone.hostedZoneId
		}
	]
 });
certificate = ListenerCertificate.fromArn(cfnCertificate.attrId);

const listener = this.loadBalancer.addListener('HttpsListener', {
	protocol: ApplicationProtocol.HTTPS,
	port: 443,
	certificates: [certificate],
	sslPolicy: SslPolicy.RECOMMENDED
});

Possible Solution

attrId property should be implemented using the Ref function.

Workaround:

The workaround is to use cfnCertificate.Ref instead of cfnCertificate.attrId

Additional Information/Context

No response

CDK CLI Version

2.147.0

Framework Version

No response

Node.js Version

22

OS

all

Language

TypeScript, Python, .NET, Java, Go

Language Version

No response

Other information

No response

@moelasmar moelasmar added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p2 labels Jun 24, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 24, 2024
@khushail
Copy link
Contributor

Hey @moelasmar , thanks for reporting this.

I found this issue is quite similar to the one you have reported and @pahud also has filed an internal ticket with Cloudformation team - #30512 (comment). However if you think, this issue is not addressed or different than the one in the mentioned internal ticket, please feel free to reach out.

@khushail khushail added needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. effort/small Small work item – less than a day of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jun 25, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 28, 2024
@github-actions github-actions bot added closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 3, 2024
@github-actions github-actions bot closed this as completed Jul 3, 2024
@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants