首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AWS CloudFormation忽略现有资源

AWS CloudFormation忽略现有资源
EN

Stack Overflow用户
提问于 2021-09-14 02:28:22
回答 1查看 781关注 0票数 0

我在CloudFormation中创建了一个堆栈,我需要帮助来改进它。在下面的堆栈中,我有一个,但是不可能两次创建它,也就是说,我不能有两个相同的服务名称。有没有人知道创建一个条件,如果创建了VPC,它就跳过了这个步骤?

代码语言:javascript
复制
  VPCEndpoint:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      ServiceName: !Join
        - ''
        - - com.amazonaws.
          - !Ref 'AWS::Region'
          - .execute-api
      PrivateDnsEnabled: true
      SecurityGroupIds: 
        - !Ref 9SecurityGroupId
      SubnetIds: 
        Ref: 8SubnetIds
      VpcEndpointType: Interface
      VpcId: 
        Ref: 7VpcId
  
  APIGateway:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: !Ref 1Name
      EndpointConfiguration:
        Types:
          - PRIVATE
        VpcEndpointIds:
          - !Ref VPCEndpoint
      Policy:
        Statement:
          - Action: 'execute-api:Invoke'
            Effect: Allow
            Principal: '*'
            Resource: 'execute-api:/*'
          - Action: 'execute-api:Invoke'
            Condition:
              StringNotEquals:
                'aws:SourceVpce': !Ref VPCEndpoint
            Effect: Deny
            Principal: '*'
            Resource: 'execute-api:/*'
        Version: 2012-10-17
EN

Stack Overflow用户

回答已采纳

发布于 2021-09-14 02:33:53

有没有人知道创建一个条件,如果创建了VPC,它就跳过了这个步骤?

是的,如果要检测到预先存在的资源,则必须创建自定义资源,以实现全自动

否则,您只需为模板创建一个输入参数,例如ShouldCreateTheInterfaceEndpoint。然后,在部署模板时,只需将其设置为falsetrue

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69171127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档