aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

AWS::Route53RecoveryControl::Cluster - [BUG] - There is no way to access clusterEndpoints return value.

Open
#2,029 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::Route53RecoveryControl::Cluster

### Resource Name

_No response_

### Issue Description

Hi, [AWS::Route53RecoveryControl::Cluster](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53recoverycontrol-cluster.html) returns a value called `ClusterEndpoints`, which is an array of objects [ClusterEndpoint](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53recoverycontrol-cluster-clusterendpoint.html).

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](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html) 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**):

```json
{
"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:

```ts
const cfnCluster = new route53recoverycontrol.CfnCluster(this, 'Cluster', {
name: 'ARC-Test',
});

const handler = new Function(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-2
const 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(
new PolicyStatement({
actions: ['route53-recovery-control-config:DescribeCluster'],
resources: [cfnCluster.attrClusterArn],
}),
);

const describeClusterResult = new cdk.CustomResource(this, 'DescribeClusterResult', {
serviceToken: handler.functionArn,
resourceType: 'Custom::DescribeClusterResult',
properties: { ClusterArn: cfnCluster.attrClusterArn },
});

const clusterEndpoints = describeClusterResult.getAttString('endpoints');
const clusterEndpointRegions = describeClusterResult.getAttString('regions');
```

Contributor guide

Open the contributing guide

Research direction

Start with the AWS::Route53RecoveryControl::Cluster resource documentation and the GetAtt intrinsic-function documentation, then reproduce the provided Outputs template in us-east-1. Done means establishing whether an individual ClusterEndpoints endpoint can be exposed to a Lambda environment variable and documenting the supported behavior or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.