Reputation: 29209
Is it a way to reference a resource of another CloudFormation which is not outputted?
For example, in file1.yaml
Resource:
SG1:
Type: AWS::EC2::SecurityGroup
....
And in file2.yaml, I will need to reference SG1
SGMSKClusterIgress6:
Type: AWS::EC2::SecurityGroupIngress
Properties:
SourceSecurityGroupId: SG1 # How to reference SG1 here
GroupId: !ImportValue MySecurityGroup
IpProtocol: tcp
FromPort: 443
ToPort: 443
I know if there is Outputs
in the file1.yaml, for example,
Resource:
SG1:
Type: AWS::EC2::SecurityGroup
....
Outputs:
SG1Output:
Value: !Ref SG1
Export:
Name: File1SG1
I can use it in file2.yaml as
SourceSecurityGroupId: !ImportValue File1SG1 # SG1 output name
What if it's not outputted? Do I has to modify file1.yaml to add the Outputs
section and update the provisioned product?
Upvotes: 0
Views: 782
Reputation: 191
Yes for referencing resources in terms of CloudFormation, you should use outputs. In case that you don't have access to file1.yaml, you can create a parameter in file2.yaml where you specify security group id and reference it in resource creation
Upvotes: 2