简体   繁体   中英

Does AWS CloudFormation support Tags Property Attribute for AWS::EC2::VPCEndpoint

I have been trying to create endpoints for my two vpc's, it is creating the vpc's, but it is not working with the Tags property which i require to name the vpc endpoint created.

Error: "Encountered unsupported property Tags"

{
  "Resources": {
        "VPCEndpoint1": {
            "Type" : "AWS::EC2::VPCEndpoint",
            "Properties" : {
                "PrivateDnsEnabled" : "True",
                "RouteTableIds" : ["rtb-1"],
                "ServiceName" : "com.amazonaws.eu-west-1.s3",
                "VpcEndpointType" : "Gateway",
                "VpcId" : "vpc-id1",
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "name1"
                    }
                ]
            }
        },
        "VPCEndpoint2": {
            "Type" : "AWS::EC2::VPCEndpoint",
            "Properties" : {
                "PrivateDnsEnabled" : "True",
                "RouteTableIds" : ["rtb-2"],
                "ServiceName" : "com.amazonaws.eu-west-1.s3",
                "VpcEndpointType" : "Gateway",
                "VpcId" : "vpc-id2",
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "name2"
                    }
                ]
            }
        }
    }
}

Cloudformation do not support Tags property.

Refer cloudformation document => https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html

Tags are supported for AWS::EC2::VPC, But not for AWS::EC2::VPCEndpoint.

If, you need tags, create tags on vpc level, not on endpoints.

VPC Level Tags - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc.html

CloudFormation does not support tagging VPC Endpoints yet.

See https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/196


Here is a workaround to tag your VPCE in CloudFormation:

You can setup the custom resource and macro from https://github.com/awslabs/aws-cloudformation-templates/tree/55ebf9f7129e87530e68c242d7e46167e6a798b8/aws/services/CloudFormation/MacrosExamples/Boto3

The code is 4 years old, so it needs to be updated:

  • Use python3.9
  • Move lambda code to InlineCode in template to replace urllib2 with cfnresponse
  • Remove calls to json.dumps
  • Remove property case lowering

Then you should be able to add a tag using CloudFormation like this:

VpceTagName:
  Type: Boto3::ec2.create_tags
  Properties:
    Resources:
      - !Ref VpcEndpoint
    Tags:
      - Key: Name
        Value: My VPCE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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