Created
December 4, 2019 00:11
-
-
Save PatMyron/c1940c37d2a6fea0fa950a107d485b81 to your computer and use it in GitHub Desktop.
Template format error: Unrecognized resource types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: | |
CreateResource: | |
Default: false | |
Type: String | |
AllowedValues: [true, false] | |
Conditions: | |
ShouldCreateResource: | |
!Equals [true, !Ref CreateResource] | |
Resources: | |
Macro: | |
Type: AWS::CloudFormation::Macro | |
Properties: | |
FunctionName: !Ref Function | |
Name: macro | |
Function: | |
Type: AWS::Lambda::Function | |
Properties: | |
Runtime: python3.7 | |
Role: !GetAtt Role.Arn | |
Code: | |
ZipFile: | | |
def lambda_handler(event, context): | |
if event['params']['CreateResource'] == 'false': | |
return {'fragment': {'Type': 'AWS::CloudFormation::WaitConditionHandle'}, | |
'requestId': event['requestId'], | |
'status': 'success'} | |
else: | |
return {'fragment': event['fragment'], | |
'requestId': event['requestId'], | |
'status': 'success'} | |
Handler: index.lambda_handler | |
Role: | |
Type: AWS::IAM::Role | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Action: sts:AssumeRole | |
Principal: | |
Service: lambda.amazonaws.com | |
Stack: | |
Fn::Transform: # these lines must be added in a separate commit after the macro | |
Name: macro # these lines must be added in a separate commit after the macro | |
Parameters: # these lines must be added in a separate commit after the macro | |
CreateResource: !Ref CreateResource # these lines must be added in a separate commit after the macro | |
Type: AWS::AppStream::Stack | |
Condition: ShouldCreateResource |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aws cloudformation validate-template
/aws cloudformation get-template-summary
/aws cloudformation create-stack-set
throw:Template format error: Unrecognized resource types: []
aws cloudformation create-stack
/aws cloudformation update-stack
cannot be called through the console without hitting:Template format error: Unrecognized resource types: []
aws cloudformation create-change-set --change-set-type IMPORT
has similar issues through the consolehttps://code.amazon.com/packages/AWS21StackBuilderService/blobs/74ba401db270b8329b602a3218f0bb608a2e74f7/--/src/amzn/aws21/sbs/utils/ResourceTypeValidator.java#L22
We should not throw this error where we cannot evaluate conditions
Currently, there is a workaround of adding a transform like
Transform: AWS::Serverless-2016-10-31
to your template like this:This workaround seems to work for the console, validate-template, get-template-summary --template-body, but not get-template-summary --stack-name or create-stack-set
While this might require adding a
CAPABILITY_AUTO_EXPAND
capability, "there is no charge incurred when using this transform" and it shouldn't affect your template if you don't have anyAWS::Serverless
resources, and you should already be using this transform if you do haveAWS::Serverless
resourcesAnother workaround that works with get-template-summary --stack-name too is a AWS::CloudFormation::Macro that removes that resource type from your template depending on the parameter value:
This might require adding both
CAPABILITY_AUTO_EXPAND
andCAPABILITY_IAM
capabilities