使用 CloudFormation 创建 AWS VPC 终端节点

Jac*_*ynn 3 amazon-web-services amazon-cloudformation amazon-vpc

我目前正在研究使用 CloudFormation 在我们的堆栈中自动创建VPC 端点(目的是让我们的堆栈可以访问 S3 而不会创建出站流量)。问题是,我似乎找不到任何说明如何声明资源的文档。 此页面似乎充满了有关将 VPC 端点与 cloudformation 结合使用的警告,我一定会注意这些警告,但我似乎找不到有关 CFN 资源本身的任何文档。

小智 5

这就是你要找的:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html

AWS::EC2::VPCEndpoint

AWS::EC2::VPCEndpoint 资源创建了一个 VPC 终端节点,您可以使用该终端节点在您的 VPC 和另一个 AWS 服务之间建立私有连接,而无需通过 Internet、VPN 连接或 AWS Direct Connect 进行访问。

快速样品:

"S3Enpoint" : {
    "Type" : "AWS::EC2::VPCEndpoint",
    "Properties" : {
        "PolicyDocument" : {
            "Version":"2012-10-17",
            "Statement":[{
                "Effect":"Allow",
                "Principal": "*",
                "Action":["s3:GetObject"],
                "Resource":["arn:aws:s3:::examplebucket/*"]
            }]
        },
        "RouteTableIds" : [ {"Ref" : "routetableA"}, {"Ref" : "routetableB"} ],
        "ServiceName" : { "Fn::Join": [ "", [ "com.amazonaws.", { "Ref": "AWS::Region" }, ".s3" ] ] },
        "VpcId" : {"Ref" : "VPCID"}
    }
}
Run Code Online (Sandbox Code Playgroud)