You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So how can we reference each value of the array, e.g. the endpoint of the first element? As far as I read the document, there is no way to handle an array of objects with GetAtt intrinsic function.
Usecase: I want to pass the endpoint of the cluster to Lambda environment variable.
Expected Behavior
We can access clusterEndpoints return value just like other string return values.
Observed Behavior
We cannot access clusterEndpoints return value.
Test Cases
Template to test (Note that ARC can only be deployed in us-east-1 region):
{
"Resources": {
"Cluster": {
"Type": "AWS::Route53RecoveryControl::Cluster",
"Properties": {
"Name": "ARC-test"
}
}
},
// THE BELOW IS INVALID"Outputs": {
"Exportaa": {
"Value": {
"Fn::Select": [
0,
{
"Fn::GetAtt": [
"Cluster",
"ClusterEndpoints"// How can we reference the endpoint?
]
}
]
},
"Export": {
"Name": "aa"
}
}
}
}
Other Details
Workaround: use custom resource to get these values. CDK Example:
constcfnCluster=newroute53recoverycontrol.CfnCluster(this,'Cluster',{name: 'ARC-Test',});consthandler=newFunction(this,'DescribeClusterHandler',{runtime: Runtime.NODEJS_20_X,handler: 'index.handler',timeout: cdk.Duration.seconds(30),code: Code.fromInline(`const response = require('cfn-response');const sdk = require('@aws-sdk/client-route53-recovery-control-config');// Route53RecoveryControlConfig API is only available on us-west-2const client = new sdk.Route53RecoveryControlConfigClient({region: 'us-west-2'});exports.handler = async function(event, context) { try { console.log(event); if (event.RequestType == 'Delete') { return await response.send(event, context, response.SUCCESS); } const clusterArn = event.ResourceProperties.ClusterArn; // https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/route53-recovery-control-config/command/DescribeClusterCommand/ const command = new sdk.DescribeClusterCommand({ClusterArn: clusterArn}); const res = await client.send(command); const clusterEndpoints = res.Cluster.ClusterEndpoints; const endpoints = clusterEndpoints.map(c=>c.Endpoint).join(','); const regions = clusterEndpoints.map(c=>c.Region).join(','); await response.send(event, context, response.SUCCESS, {endpoints, regions}, clusterArn); } catch (e) { console.log(e); await response.send(event, context, response.FAILED); }};`),});handler.addToRolePolicy(newPolicyStatement({actions: ['route53-recovery-control-config:DescribeCluster'],resources: [cfnCluster.attrClusterArn],}),);constdescribeClusterResult=newcdk.CustomResource(this,'DescribeClusterResult',{serviceToken: handler.functionArn,resourceType: 'Custom::DescribeClusterResult',properties: {ClusterArn: cfnCluster.attrClusterArn},});constclusterEndpoints=describeClusterResult.getAttString('endpoints');constclusterEndpointRegions=describeClusterResult.getAttString('regions');
The text was updated successfully, but these errors were encountered:
Name of the resource
AWS::Route53RecoveryControl::Cluster
Resource Name
No response
Issue Description
Hi, AWS::Route53RecoveryControl::Cluster returns a value called
ClusterEndpoints
, which is an array of objects ClusterEndpoint.So how can we reference each value of the array, e.g. the endpoint of the first element? As far as I read the document, there is no way to handle an array of objects with GetAtt intrinsic function.
Usecase: I want to pass the endpoint of the cluster to Lambda environment variable.
Expected Behavior
We can access clusterEndpoints return value just like other string return values.
Observed Behavior
We cannot access clusterEndpoints return value.
Test Cases
Template to test (Note that ARC can only be deployed in us-east-1 region):
Other Details
Workaround: use custom resource to get these values. CDK Example:
The text was updated successfully, but these errors were encountered: