How do I resolve the "Attribute 'Key' does not exist" error when I use the Fn::GetAtt function on my resource provider resource in AWS CloudFormation?
Last updated: 2020-08-17
I receive the "Attribute 'Key' does not exist" error when I use the Fn::GetAtt function on my resource provider resource in AWS CloudFormation. How can I resolve this error?
Short description
You receive the "Attribute 'Key' does not exist" error when the ReadHandler of your resource doesn't return a property specified from the list readOnlyProperties in the resource provider schema file organization-service-resource.json. AWS CloudFormation returns this error because it isn't receiving the required property.
If you're having issues with other errors related to using a resource provider, see the following articles for additional troubleshooting steps:
- How do I resolve the "Resource specification is invalid" error when I run the cfn generate command using the CloudFormation CLI in AWS CloudFormation?
- How do I resolve the "Model validation failed (#: extraneous key [Key] is not permitted)" error in AWS 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 AWS CloudFormation?
- How do I resolve the "java.lang.ClassNotFoundException: com.example.package.resource.HandlerWrapper" error in AWS CloudFormation?
Resolution
1. In your organization-service-resource.json file, confirm that the readOnlyProperties definition follows this format, where Output is a property defined in the properties section. For example:
"readOnlyProperties": [
"/properties/Output"
],
Note: The resource provider schema file is a JSON file in the organization-service-resource.json format and is located in the root directory of your project.
2. In your ReadHandler, set the property (in the follow example, Output) 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
Did this article help?
Do you need billing or technical support?