How do I resolve the "Attribute 'Key' does not exist" error when I use the Fn::GetAtt function on my resource provider resource in CloudFormation?

2 minute read
0

When I use the Fn::GetAtt function on my resource provider in AWS CloudFormation, I receive the following error: "Attribute 'Key' does not exist"

Short description

CloudFormation returns the "Attribute 'Key' does not exist" error because it isn't receiving the required property. The ReadHandler of your resource must return a property that's specified from the readOnlyProperties list in the organization-service-resource.json resource provider schema file.

For other errors that are related to using a resource provider, see the following articles:

Resolution

1.    In your organization-service-resource.json file, confirm that the readOnlyProperties definition uses the following format, where Output is a property that's defined in the properties section. For example:

"readOnlyProperties": [
    "/properties/Output"
],

Note: The organization-service-resource.json format is located in the root directory of your project.

2.    In your ReadHandler, set the property in the model object. For example:

final ResourceModel model = request.getDesiredResourceState();
model.setOutput("abcdxyz");
return ProgressEvent.<ResourceModel, CallbackContext>builder()
    .resourceModel(model)
    .status(OperationStatus.SUCCESS)
    .build();

Related information

AWS CloudFormation CLI (from the GitHub website)

AWS OFFICIAL
AWS OFFICIALUpdated a year ago
No comments