简体   繁体   English

cloudformation 模板中的现有动态 AWS 资源

[英]Existing dynamic AWS resources in cloudformation template

I have already created AWS network resources(VPC,subnets,IGW etc) through AWS console.我已经通过 AWS 控制台创建了 AWS 网络资源(VPC、子网、IGW 等)。 Now, I am trying to create a cloudformation stack consisting of those existing & new resources.现在,我正在尝试创建一个由现有和新资源组成的 cloudformation 堆栈。 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?问题1:这是正确的方法吗? (As we have diff envs so to handle dynamic AWS resources, I am doing this) (因为我们有 diff envs 来处理动态 AWS 资源,所以我正在这样做)

Question 2: I am able to set parameter with VPC,subnets but not with Internet gateway.问题 2:我可以使用 VPC、子网设置参数,但不能使用 Internet 网关。 How to put internetgateway as a parameter?如何将 internetgateway 作为参数?

Thanks谢谢

Question 1: Is this the right approach?问题1:这是正确的方法吗? (As we have diff envs so to handle dynamic AWS resources, I am doing this) (因为我们有 diff envs 来处理动态 AWS 资源,所以我正在这样做)

Its one way of doing this.它是这样做的一种方式。 If you want to be able to select different subnet or vpc at template creation then its fine.如果您希望能够在创建模板时使用 select 不同的子网或 vpc,那就可以了。 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.但是,如果 VPC 和子网是固定的并且不会更改,那么最好将它们从自己的堆栈中导出,然后将它们导入到其他堆栈中。 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.问题 2:我可以使用 VPC、子网设置参数,但不能使用 Internet 网关。 How to put internetgateway as a parameter?如何将 internetgateway 作为参数?

Unfortunatly, there is no such parameter like AWS::EC2::InternetGateway::Id .不幸的是,没有像AWS::EC2::InternetGateway::Id这样的参数 In this case you would have to use String :在这种情况下,您将不得不使用String

  InternetGateway:
    Type: String

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM