I am creating an AWS AMI that is provisioned with Chef using Packer. At the creation of snapshots tags of the AWS AMI, I want it to be tagged with tags that assign it to be deployed with CodeDeploy:
{
"aws:autoscaling:groupName": "Env1"
}
In my JSON configuration for Packer, I am using snapshot_tags to define these.
The problem is that on creating the AMI, Packer fails with:
Build 'amazon-ebs' errored: Error adding tags to Resources ([]*string{(*string)(0xc420107170), (*string)(0xc420478758)}): InvalidParameterValue: Tag keys starting with 'aws:' are reserved for internal use
status code: 400, request id: fef34822-b692-4225-a2eb-a1cfac33a924
Cannot I use CodeDeploy with Packer since I must use aws in the tag?
ANSWER:
There is no need to use a tag for an AMI to deploy with CodeDeploy. My mistake.
Don't know about CodeDeploy, but you can never create a tag which starts with aws:.
Do not use the aws: prefix in your tag names or values because it is reserved for AWS use. You can't edit or delete tag names or values with this prefix. Tags with this prefix do not count against your tags per resource limit.
See AWS Docs: Using Tags - tag restrictions
Related
I have multiple existing EBS snapshots that I would like to tag using terraform. Say the tag key is "cost_center" and value is "11111" I'd like to build a terraform code that would add this tag to multiple snapshot >50. Does this fall under resource tagging or another
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_snapshot
I'd like to enable/allow this AWS EC2 Instance Setting "Access to tags in instance metadata" using one of my Terraform's resources aws_launch_configuration OR aws_autoscaling_group.
I have tried to use this argument metadata_options of aws_launch_configuration resource but it did not work.
In addition find this GitHub Issue aws_launch_configuration add support for Instance Metadata Options #14621
How can I solve this issue?
As per the AWS Cloudformation documentation
it is mentioned that Cloudformation automatically provides stack-level tags to resources.
aws:cloudformation:logical-id
aws:cloudformation:stack-id
aws:cloudformation:stack-name
I could see that for resources like EC2, S3, etc.
But when it comes to EMR I couldn’t see those tags. I need aws:cloudformation:stack-id tag value, so that I can later identify stackId without any hustle.
Isn’t it supported for EMR?
If not what could be workaround? I need to add CF stackId using which I can easily identify the stack for other use.
Note: aws cloudformation describe-stack-resources --physical-resource-id j-XXXXXXXXXXX this is not an option to get stackId because of not having enough IAM politics.
How I'm creating EMR cluster: I have one lambda which invokes CloudFormation using boto3, which then created the cluster.
I checked that on my EMR cluster and CloudFormation. You are correct. Tags are no where to be seen.
Could be oversight on AWS part, as they explicitly write in the docs that only EBS volumes don't have such tags:
All stack-level tags, including automatically created tags, are propagated to resources that AWS CloudFormation supports. Currently, tags are not propagated to Amazon EBS volumes that are created from block device mappings.
The only workaround I can think of is to "manually" create such tags, e.g. using custom resources. Or as you are already using lambda, do it in your lambda after EMR cluster creation.
I have an elastic beanstalk environment created with CloudFormation. Now I've added an additional tag and value but during the update of the stack I get:
Elastic Beanstalk environment tags cannot be updated.
Is there a way to fix this? I don't want to delete the environment and bring it back up.
According to AWS documentation for Cloudformation ElasticBeanstalk Environment, for Tags we have the following update policy:
Update requires: You can update tags only if you update another
property that requires that the environment be replaced, such as the
ApplicationName property.
Which means you cannot update tags without rebuilding the environment using cloudformation.
However, you can update tags outside of cloudformation stack -
Tagging Resources in Your Elastic Beanstalk Environment:
You can specify tags when you create the Elastic Beanstalk
environment. In an existing environment, you can add or remove tags,
and you can update the values of existing tags. In addition to the
default tags, you can add up to 47 additional tags to each
environment.
Be careful, as changing stack resources outside of cloudformation is not recommended and may lead to Cloudformation stack drift
I'm trying to figure out how to specify a resource group name when creating resource groups via aws cli, when I look at the cli documentation for create-resource-group command I only see option to specify tags, how do you specify a name? , also I noticed when I access the console I don't see resource groups created using cli. Any ideas?