1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
You can do this, but it can get quickly rather complex. I have done it like this Have parameters for everything. If you already have the resource, input your resource ID, and if you want to create a new one, leave it empty. For example NAT GW Elastic IP parameter
EipA:
Type: String
Description: Pre-allocated EIP ID for AZ-A (optional)
Default: ''
Then in Conditions block, check if parameters has a value or if it is left empty
CreateEipA: !Equals [!Ref EipA, "" ]
Then use the condition when creating (or not) creating the resource
NatEipA:
Type: AWS::EC2::EIP
Condition: CreateEipA
Properties:
Domain: vpc
And finally when creating the NAT GW select if you want to use parameter value or reference to resource that was created.
NatGwA:
Type: AWS::EC2::NatGateway
Properties:
ConnectivityType: public
SubnetId: !Ref PubSubnetA
AllocationId: !If [ CreateEipA, !GetAtt NatEipA.AllocationId, !Ref EipA ]
Contenus pertinents
- demandé il y a un an
- demandé il y a un an
- demandé il y a 7 mois
- AWS OFFICIELA mis à jour il y a 3 ans
- AWS OFFICIELA mis à jour il y a 2 ans
I got your point, but I was looking for something like infusing a "create new" option in the dropdown where it dynamically gather all the existing resources. VpcId: Type: AWS::EC2::VPC::Id Description: Select an existing VPC
Yes, it would be nice if you could input an empty value (or even better, insert your own values to list) when using parameter types like VPC::Id. Unfortunately that is not supported. I guess the closest thing you can get is to add an extra "yes/no" paramater to select if given resource should be used or create a new, but this isn't very intuitive for user.