标记使用 cloudformation 创建的 Beanstalk 环境
Tagging Beanstalk environments created with cloudformation
使用Cloud Formation创建Elastic Beanstalk环境时,如何设置分配给环境和实例的Tags?
例如我有以下资源定义:
"BeanstalkEnvironment" : {
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "BeanstalkApplication" },
"Description" : "AWS Elastic Beanstalk Environment running Demo Application",
"SolutionStackName" : "64bit Windows Server 2012 R2 running IIS 8.5",
"EnvironmentName" : "Test Site",
"CNAMEPrefix" : { "Ref" : "URLPrefix" },
"OptionSettings" : [
{"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName" : "EC2KeyName", "Value" : { "Ref" : "KeyName" }},
{"Namespace" : "aws:ec2:vpc", "OptionName" : "VPCId", "Value" : { "Ref" : "VPC" }},
{"Namespace" : "aws:ec2:vpc", "OptionName" : "Subnets", "Value" : { "Fn::Join" : [ ",", [ { "Ref" : "SubnetA" }, { "Ref" : "SubnetB" }, { "Ref" : "SubnetC" } ] ] } },
{"Namespace" : "aws:ec2:vpc", "OptionName" : "ELBSubnets", "Value" : { "Fn::Join" : [ ",", [ { "Ref" : "SubnetA" }, { "Ref" : "SubnetB" }, { "Ref" : "SubnetC" } ] ] } },
{"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName":"InstanceType", "Value" : "t2.micro" },
{"Namespace" : "aws:ec2:vpc", "OptionName":"AssociatePublicIpAddress", "Value":"true" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"MaxBatchSize", "Value": "1" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"MinInstancesInService", "Value": "1" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"PauseTime", "Value": "PT5M30S" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"RollingUpdateEnabled", "Value": "true" },
{"Namespace" : "aws:elasticbeanstalk:command", "OptionName":"BatchSize", "Value": "30" },
{"Namespace" : "aws:elb:policies", "OptionName":"ConnectionDrainingEnabled", "Value": "true" }
],
"VersionLabel" : "Sample .NET Application"
}
}
完整的工作示例模板位于 this gist。
并且想向 Beanstalk 及其创建的实例添加一组标签,例如:
"Tags" : [
{ "Key" : "Contact", "Value" : { "Ref" : "Contact" } },
{ "Key" : "BudgetCode", "Value" : { "Ref" : "BudgetCode" } }
]
Elastic Beanstalk Resource Type in the same way there is for other types (e.g. S3 Buckets).
似乎没有 "Tags" 元素
关于如何做到这一点有什么建议吗?确保正确标记创建的实例非常好,这样我们就可以跟踪哪些实例用于不同的项目。
我希望我有答案,但我遇到了同样的问题。您可以在创建环境 cli 和 api 中执行此操作,但在 cloudformation 模板中执行此操作的选项设置中似乎没有用于此操作的命名空间。 (至少它不是我所看到的记录的命名空间)。我的 google-fu 也没有向任何其他人展示对此的答案。
我遇到了同样的问题,亚马逊支持人员表示这是功能上的缺陷。
OP 中给出的示例现在应该可以使用了。
AWS 在 2015 年 8 月 24 日添加了对标记 Elastic Beanstalk 环境的支持:
http://aws.amazon.com/about-aws/whats-new/2015/08/aws-cloudformation-updates-support-for-amazon-vpc-aws-lambda-aws-elastic-beanstalk-amazon-rds-and-amazon-s3/
用法与支持标签的其他 CFN 资源类型相同 - 在 Properties 映射中包含 Tags 键并分配键值映射列表:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-beanstalk-environment.html#cfn-beanstalk-environment-tags
使用Cloud Formation创建Elastic Beanstalk环境时,如何设置分配给环境和实例的Tags?
例如我有以下资源定义:
"BeanstalkEnvironment" : {
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "BeanstalkApplication" },
"Description" : "AWS Elastic Beanstalk Environment running Demo Application",
"SolutionStackName" : "64bit Windows Server 2012 R2 running IIS 8.5",
"EnvironmentName" : "Test Site",
"CNAMEPrefix" : { "Ref" : "URLPrefix" },
"OptionSettings" : [
{"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName" : "EC2KeyName", "Value" : { "Ref" : "KeyName" }},
{"Namespace" : "aws:ec2:vpc", "OptionName" : "VPCId", "Value" : { "Ref" : "VPC" }},
{"Namespace" : "aws:ec2:vpc", "OptionName" : "Subnets", "Value" : { "Fn::Join" : [ ",", [ { "Ref" : "SubnetA" }, { "Ref" : "SubnetB" }, { "Ref" : "SubnetC" } ] ] } },
{"Namespace" : "aws:ec2:vpc", "OptionName" : "ELBSubnets", "Value" : { "Fn::Join" : [ ",", [ { "Ref" : "SubnetA" }, { "Ref" : "SubnetB" }, { "Ref" : "SubnetC" } ] ] } },
{"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName":"InstanceType", "Value" : "t2.micro" },
{"Namespace" : "aws:ec2:vpc", "OptionName":"AssociatePublicIpAddress", "Value":"true" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"MaxBatchSize", "Value": "1" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"MinInstancesInService", "Value": "1" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"PauseTime", "Value": "PT5M30S" },
{"Namespace" : "aws:autoscaling:updatepolicy:rollingupdate", "OptionName":"RollingUpdateEnabled", "Value": "true" },
{"Namespace" : "aws:elasticbeanstalk:command", "OptionName":"BatchSize", "Value": "30" },
{"Namespace" : "aws:elb:policies", "OptionName":"ConnectionDrainingEnabled", "Value": "true" }
],
"VersionLabel" : "Sample .NET Application"
}
}
完整的工作示例模板位于 this gist。
并且想向 Beanstalk 及其创建的实例添加一组标签,例如:
"Tags" : [
{ "Key" : "Contact", "Value" : { "Ref" : "Contact" } },
{ "Key" : "BudgetCode", "Value" : { "Ref" : "BudgetCode" } }
]
Elastic Beanstalk Resource Type in the same way there is for other types (e.g. S3 Buckets).
似乎没有 "Tags" 元素关于如何做到这一点有什么建议吗?确保正确标记创建的实例非常好,这样我们就可以跟踪哪些实例用于不同的项目。
我希望我有答案,但我遇到了同样的问题。您可以在创建环境 cli 和 api 中执行此操作,但在 cloudformation 模板中执行此操作的选项设置中似乎没有用于此操作的命名空间。 (至少它不是我所看到的记录的命名空间)。我的 google-fu 也没有向任何其他人展示对此的答案。
我遇到了同样的问题,亚马逊支持人员表示这是功能上的缺陷。
OP 中给出的示例现在应该可以使用了。
AWS 在 2015 年 8 月 24 日添加了对标记 Elastic Beanstalk 环境的支持: http://aws.amazon.com/about-aws/whats-new/2015/08/aws-cloudformation-updates-support-for-amazon-vpc-aws-lambda-aws-elastic-beanstalk-amazon-rds-and-amazon-s3/
用法与支持标签的其他 CFN 资源类型相同 - 在 Properties 映射中包含 Tags 键并分配键值映射列表: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-beanstalk-environment.html#cfn-beanstalk-environment-tags