aws-cloudformation / cloudformation-coverage-roadmap

The AWS CloudFormation Public Coverage Roadmap
https://aws.amazon.com/cloudformation/
Creative Commons Attribution Share Alike 4.0 International
1.11k stars 54 forks source link

Using Fn::Import with ChangeSet that IncludeNestedStacks set to True gives error "TemplateURL must be a supported URL." #1212

Open shantgup opened 2 years ago

shantgup commented 2 years ago

Name of the resource

AWS::CloudFormation::Stack

Resource Name

No response

Issue Description

Using Fn::Import in template when creating a ChangeSet with IncludeNestedStacks set to True gives error "TemplateURL must be a supported URL."

See template below.

Parameters:
    MyExportName:
        Type: String

Resources:
    Stack: 
        Type: AWS::CloudFormation::Stack
        Properties:
            TemplateURL: 
                Fn::Sub:
                - https://${BucketName}.s3.${AWS::Region}.amazonaws.com/template.yaml 
                - BucketName:
                    Fn::ImportValue: !Sub ${SSMParameter}-Export

This also fails when trying to use Fn::ImportValue under Fn::Join.

I suspect that the IncludeNestedStacks feature when creating changesets does not work with Fn::ImportValue. Because if I specify IncludeNestedStacks to false, the error goes away.

Removing Fn::ImportValue also fixes this issue.

Expected Behavior

It should not fail.

Observed Behavior

It fails with the error TemplateURL must be a supported URL.

Test Cases

Create a changeset with a template that has an AWS::CloudFormation::Stack resource, with TemplateURL using Fn::ImportValue, like the above example.

Other Details

No response

farski commented 2 years ago

I get the same TemplateURL must be a supported URL error when a the TemplateURL includes a reference to a stack ouput. For example:

TemplateURL: !Sub ${SomeStack.SomeStackOuput}/buckets.yml

I'm assuming here that the issue is related to stack outputs, and not simply an issue with !GetAtt, but I have not confirmed that.