【问题标题】:Creating a VPC Interface Endpoint for SQS in Cloud Formation在 Cloud Formation 中为 SQS 创建 VPC 接口端点
【发布时间】:2019-07-05 17:20:17
【问题描述】:

我想知道是否可以在我的 CloudFormation 文件中创建一个资源来为 SQS 创建一个 VPC 端点。我能够为 SQS 和 DynamoDB 做到这一点,但我相信这是因为它们是网关端点。

现在我已将我的 SQS 资源定义为:

SQSEndpoint:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal: '*'
            Action:
              - 'sqs:*'
            Resource:
              - '*'
      ServiceName: !Join 
        - ''
        - - com.amazonaws.
          - !Ref 'AWS::Region'
          - .sqs
      SubnetIds:
        - !Ref PrivateSubnet
        - !Ref PublicSubnet
      VpcId: !Ref 'VPC'
      VpcEndpointType: Interface

但是,当我尝试创建堆栈时,我得到了错误:

似乎可以从 AWS 读取 this blog post。虽然我找不到任何示例或文档。有什么想法吗?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-vpc


    【解决方案1】:

    我想通了,对于使用网关端点的 DynamoDB 和 S3,必须定义 PolicyDocument 属性。对于所有其他服务,这不需要定义。因此,对于 SQS,所需要的只是:

     SQSEndpoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Join 
            - ''
            - - com.amazonaws.
              - !Ref 'AWS::Region'
              - .sqs
          SubnetIds:
            - !Ref PrivateSubnet
            - !Ref PublicSubnet
          VpcId: !Ref 'VPC'
          VpcEndpointType: Interface
    

    编辑: 即使设置了接口端点,仍然无法正常工作,我必须:

    1. PrivateDnsEnabled 属性设置为 true 以便您可以使用 AWS CLI,因为 AWS CLI 使用公共终端节点,设置 PrivateDnsEnabled 允许私有终端节点自动映射到公共终端节点一个

    2. SecurityGroupsIds 设置为具有允许来自您的 VPC 的入站流量的安全组。如果设置此实例,则使用默认安全组,它只允许来自具有默认安全组的来源的入站流量,这意味着SQS 将无法将流量发送回您的实例

    总结一下:

      SQSEndpoint:
        Type: AWS::EC2::VPCEndpoint
        Properties:
          ServiceName: !Join 
            - ''
            - - com.amazonaws.
              - !Ref 'AWS::Region'
              - .sqs
          SubnetIds:
            - !Ref PrivateSubnet
          VpcId: !Ref 'VPC'
          VpcEndpointType: Interface
          SecurityGroupIds:
            - !Ref PrivateSubnetInstanceSG # has to allow traffic from your VPC
          PrivateDnsEnabled: true
    

    【讨论】:

      猜你喜欢
      • 2019-05-01
      • 1970-01-01
      • 2020-02-17
      • 2020-09-08
      • 2023-02-07
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多