微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用Cloudformation创建具有面向互联网的VPC终端节点的AWS SFTP服务器?

如何解决如何使用Cloudformation创建具有面向互联网的VPC终端节点的AWS SFTP服务器?

我能够在VPC内创建一个SFTP服务器(AWS传输系列),并在AWS控制台上具有面向互联网的端点,如下所述:https://docs.aws.amazon.com/transfer/latest/userguide/create-server-in-vpc.html

VPC endpoint type access selection

现在,我需要在CloudFormation模板中复制相同的创建内容,并且不知道如何执行(如果可能)。根据我在https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-transfer-server-endpointdetails.html和相应的CDK文档https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-transfer.CfnServer.EndpointDetailsProperty.html中看到的内容,似乎没有设置“ access”属性值的可能性。

我遇到的所有示例都使用PUBLIC端点(与VPC相反)。这是我正在处理的片段:

"Resources": {
  "ftpserver": {
    "Type": "AWS::Transfer::Server","DependsOn": "sftpEIP1","Properties": {
      "EndpointDetails": {
        "subnetIds": [
          {
            "Ref": "sftpsubnet1"
          }
        ],"VpcId": {
          "Ref": "sftpVPC"
        }
      },"EndpointType": "VPC","Protocols": [
          "SFTP"
      ],"Tags": [
        {
          "Key": "KeyName","Value": "ValueName"
        }
      ]
    }
  }
},...      
}

由于无法在CloudFormation中设置访问类型,因此最终将终端创建为“内部”,而不是我需要的“面向Internet”。

有没有解决办法,还是应该在每次部署后手动更改(AWS控制台)?

解决方法

您需要关联弹性IP并定义安全组。

请注意,因为仅在创建服务器后才能添加弹性IP,所以要花一些时间才能完成,CloudFormation实际上仅使用内部服务器创建服务器,停止服务器,添加弹性IP,然后再次使用弹性IP和互联网启动面对,然后完成堆叠。

下面带有CF模板的示例可以正常工作。

Description: Test CF with FTP server

Resources:
  ElasticIP1:
    Type: AWS::EC2::EIP
  ElasticIP2:
    Type: AWS::EC2::EIP
  ElasticIP3:
    Type: AWS::EC2::EIP

  FTPServer:
    Type: AWS::Transfer::Server
    Properties:
      EndpointDetails:
        AddressAllocationIds:
          - !GetAtt ElasticIP1.AllocationId
          - !GetAtt ElasticIP2.AllocationId
          - !GetAtt ElasticIP3.AllocationId
        SecurityGroupIds:
          - sg-0c4184c3f5da91d4a
        SubnetIds:
          - subnet-0546e2c78cebd0a60
          - subnet-0114560b841c91de7
          - subnet-0af8fb5fae5472862
        VpcId: vpc-07daf77a355f5a8e8
      EndpointType: VPC
      Protocols:
        - SFTP

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。