Skip to content

Commit f0af9e0

Browse files
authored
Tag Elastic Beanstalk EBS volumes
1 parent b5e8eae commit f0af9e0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
###################################################################################################
2+
#### Tag EBS volume Name with the Elastic Beanstalk environment name. This is the same naming
3+
#### convention used on the instances to which the volumes are attached. Without this config
4+
#### Elastic Beanstalk leaves the volume Name tag empty.
5+
#### This requires that the IAM role have EC2 Create Tag and EC2 Describe permissions since the
6+
#### volume is tagged by the instance (as opposed to the service/service role).
7+
####
8+
#### Note: According to support this is "an ongoing feature request to add support for tagging EBS
9+
#### volume by allowing the Resource tags to be propagated to the Launch Template".
10+
#### Which is to say: hopefully this will not be required at some point in future.
11+
####
12+
#### Author: @hayd
13+
###################################################################################################
14+
15+
container_commands:
16+
tagVolume:
17+
command: aws ec2 create-tags --resources $(aws ec2 describe-instances --region $(curl http://169.254.169.254/latest/meta-data/placement/availability-zone| sed 's/[a-z]$//') --instance-id $(curl http://169.254.169.254/latest/meta-data/instance-id ) --output text --query Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId) --region $(curl http://169.254.169.254/latest/meta-data/placement/availability-zone| sed 's/[a-z]$//') --tags Key=Name,Value=$(/opt/elasticbeanstalk/bin/get-config container -k environment_name)

0 commit comments

Comments
 (0)