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?
Last updated: 2022-09-19
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:
- How do I resolve the "Resource specification is invalid" error when I run the cfn generate command using the CloudFormation CLI in CloudFormation?
- How do I resolve the "Model validation failed (#: extraneous key [Key] is not permitted)" error in CloudFormation?
- How do I resolve the "Resource timed out waiting for creation of physical resource" error when I create a resource using my resource provider type in CloudFormation?
- How do I resolve the "java.lang.ClassNotFoundException: com.example.package.resource.HandlerWrapper" error in CloudFormation?
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)
Did this article help?
Do you need billing or technical support?