creating duplicate resources in the same Account using Cloudformation

0

BuildEnvironment: Type: String AllowedValues: - dev - prod - qa - qa3

InstanceSGFullAccess: Type: AWS::EC2::SecurityGroup Properties: GroupName: "Allow full access from local 10.0.0.0/8" GroupDescription: Allows full inbout and outbound access to local private address range VpcId: Fn::ImportValue: !Sub "${AWSEnvironment}-VPCID" SecurityGroupIngress: - IpProtocol: -1 CidrIp: 10.0.0.0/8
SecurityGroupEgress: - IpProtocol: -1 CidrIp: 10.0.0.0/8 Tags: - Key: "keyname1" Value: "value1"

InstanceSGOutBoundAccess: Type: AWS::EC2::SecurityGroup Properties: GroupName: "Allow outbound" GroupDescription: Allow full outbound access VpcId: Fn::ImportValue: !Sub "${AWSEnvironment}-VPCID" SecurityGroupEgress: - IpProtocol: -1 CidrIp: 0.0.0.0/0 - IpProtocol: -1 CidrIpv6: ::/0

MHCLaunchTemplate: Type: AWS::EC2::LaunchTemplate Properties: LaunchTemplateName: !Sub MRxAssist-${AWSEnvironment} LaunchTemplateData: IamInstanceProfile: Arn: !Ref IAMInstanceProfile DisableApiTermination: true ImageId: !Ref AmiId InstanceType: !Ref InstanceType KeyName: !Ref SSHKey SecurityGroupIds: - !Ref InstanceSGFullAccess - !Ref InstanceSGOutBoundAccess - !ImportValue 'Fn::Sub': '${AWSEnvironment}-OracleAccessSecurityGroup' UserData: ......

i want to make -> InstanceSGFullAccess and InstanceSGOutBoundAccess dynamic by appending the environment parameters i.e. QA or QA3 in the same account. and referring them into the MHCLaunchTemplate, so that i don't get "Resource already exists error" when running QA first and QA3 second using the same cloudformation script.

質問済み 1年前290ビュー
1回答
0
承認された回答

You can use the !Sub command to append QA or QA3 to the GroupName.

profile pictureAWS
エキスパート
kentrad
回答済み 1年前
profile picture
エキスパート
レビュー済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ