connect icon indicating copy to clipboard operation
connect copied to clipboard

ECS Example: Add some checks of Parameters to conditionally create new infrastructure

Open thatguygriff opened this issue 3 years ago • 0 comments

From @verkaufer https://github.com/1Password/connect/pull/3#issuecomment-876751089

We can do some contrived checks using Conditions and Parameters to create new resources if the parameters are some empty value:

Parameters:
  ExistingVPC: 
    Description: An existing VPC where the cluster will run (optional).
    Default: NONE
    Type: String
    
Conditions: 
  NewVPC: !Equals [!Ref ExistingVPC, NONE]
 
Resources:
  DefaultVPC:
    Type: AWS::EC2::VPC
    Properties:
      EnableDnsSupport: true
      EnableDnsHostnames: true
      CidrBlock: !FindInMap ['SubnetConfig', 'VPC', 'CIDR']
  PublicRouteTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !If [NewVPC, !Ref DefaultVPC, !Ref ExistingVPC] # use the NewVPC definition if user did not provide ExistingVPC param

thatguygriff avatar Aug 10 '21 13:08 thatguygriff