(cfnSpec): Attributes returned as integers output dummy values instead of calling getAtt
See original GitHub issueWhat is the problem?
I can’t make output value from attrClusterEndpointPort property of memorydb.CfnCluster. The generated CloudFormation template show hardcoded number value rather than reference value from AWS::MemoryDB::Cluster resource.
"Outputs": {
"MemoryDBEndpointAddress": {
"Value": {
"Fn::GetAtt": [
"MemoryDBCluster",
"ClusterEndpoint.Address"
]
}
},
"MemoryDBEndpointPort": {
"Value": "-1.888154589708829e+289"
},
Reproduction Steps
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as memorydb from 'aws-cdk-lib/aws-memorydb';
import * as elasticache from 'aws-cdk-lib/aws-elasticache';
export class BenchmarkVsElasticacheRedisStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'VPC');
const dbSecurityGroup = new ec2.SecurityGroup(this, 'DB Security Group', {
vpc
});
const subnets = vpc.selectSubnets({
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT
});
const memoryDBSubnetGroup = new memorydb.CfnSubnetGroup(this, 'MemoryDB Subnet Group', {
subnetGroupName: 'memorydb-test-subnet-group',
subnetIds: subnets.subnetIds,
});
const memoryDBCluster = new memorydb.CfnCluster(this, 'Memory DB Cluster', {
clusterName: 'memorydb-test',
nodeType: 'db.r6g.large',
aclName: 'open-access',
subnetGroupName: memoryDBSubnetGroup.subnetGroupName,
securityGroupIds: [ dbSecurityGroup.securityGroupId ],
tlsEnabled: false
});
memoryDBCluster.node.addDependency(memoryDBSubnetGroup, dbSecurityGroup);
new CfnOutput(this, 'Memory DB Endpoint Address', {
value: memoryDBCluster.attrClusterEndpointAddress
});
new CfnOutput(this, 'Memory DB Endpoint Port', {
value: memoryDBCluster.attrClusterEndpointPort.toString()
});
}
}
What did you expect to happen?
The output value of memorydb cluster’s port number should be the reference of the resource.
What actually happened?
The output value of memorydb cluster’s port number is hardcoded number value.
CDK CLI Version
2.3.0 (build beaa5b2)
Framework Version
2.3.0
Node.js Version
v16.13.1
OS
MacOS
Language
Typescript
Language Version
TypeScript (3.9.10)
Other information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Fn::GetAtt - AWS CloudFormation
Return the value of an attribute from the resource in the AWS CloudFormation template by using the Fn::GetAtt intrinsic function.
Read more >aws-cdk build is failing · Issue #6406
Total time (0.0s) @aws-cdk/cfnspec: Applying patch: Add ... returns a list with dummy values if the context is not available @aws-cdk/core: ...
Read more >@aws-cdk/aws-cloudformation | Yarn - Package Manager
grantRead(principal) (@eladb in #371); Return dummy values instead of fail synthesis if environmental context (AZs, SSM parameters) doesn't exist in order ...
Read more >AWS CloudFormation Attributes (GetAtt) Cheat Sheet
Fn::GetAtt is an important function in AWS CloudFormation that returns the value of an attribute of a given AWS resource type.
Read more >Cloudformation when to use getatt, ref, vs ${}
Ref can be used for two things: To return the value of a parameter that you passed in via the parameters section of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for reporting this @naxxster, I’m finding the same behavior with the other attributes which end up as integers. (Such as
Lightsail::Disk.Iops
)Before this is fixed, you can create the
getAtt
reference with theFn.getAtt()
function.⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.