2
votes

I have already created AWS network resources(VPC,subnets,IGW etc) through AWS console. Now, I am trying to create a cloudformation stack consisting of those existing & new resources. To implement existing resources in the stack, I am using Parameters

Parameters:
  VpcId:
    Description: VPC Id
    Type: AWS::EC2::VPC::Id

  PublicSubnetId1:
    Description: Public Subnet 1
    Type: AWS::EC2::Subnet::Id

  PublicSubnetId2:
    Description: Public Subnet 2
    Type: AWS::EC2::Subnet::Id

  InternetGateway:
    Type: AWS::EC2::InternetGateway::Id

Question 1: Is this the right approach ? (As we have diff envs so to handle dynamic AWS resources, I am doing this)

Question 2: I am able to set parameter with VPC,subnets but not with Internet gateway. How to put internetgateway as a parameter ?

Thanks

1

1 Answers

1
votes

Question 1: Is this the right approach ? (As we have diff envs so to handle dynamic AWS resources, I am doing this)

Its one way of doing this. If you want to be able to select different subnet or vpc at template creation then its fine. However, if the VPC and subnets are fixed and do not change, probably better would be to export them from their own stacks, end them import them in other stacks. This way other stacks can easily refer to them, and you have simplified deployment your stacks as you don't need to provide all these parameters for each new stack.

Question 2: I am able to set parameter with VPC,subnets but not with Internet gateway. How to put internetgateway as a parameter ?

Unfortunatly, there is no such parameter like AWS::EC2::InternetGateway::Id. In this case you would have to use String:

  InternetGateway:
    Type: String