node.js - Tag AWS beanstalk deployment using .config file in .ebextensions -
i added scripts.config file .ebextensions @ root of node app deployed in beanstalk.i did not see tags ec2 instances in console. nor did see mention of 1_add_tags in beanstalk logs. did wrong , how find out if commands in script.config called @ all!
the config file in .ebextensions follows ....
01_add_tags:
command: ec2-create-tags $(ec2-metadata -i | cut -d ' ' -f2) --tag environment=production --tag name=proxy-server --tag application=something
env:
ec2_home: /opt/aws/apitools/ec2 ec2_url: https://ec2.ap-southeast-2.ama... java_home: /usr/lib/jvm/jre path: /bin:/usr/bin:/opt/aws/bin/
cheers,
prabin
amazon's answer problem. (this worked me) ...
you can utilise ebextensions execute commands on instance boot. supposing want implement on linux based containers. have formulated sample config file , attached case.
please follow below guidelines :
- in aws management console, check iam role/instance profile used beanstalk. default uses "aws-elasticbeanstalk-ec2-role". add permissions role create new tags (ec2:createtags).
- if not have ".ebextensions" folder @ root of application or "web-inf" folder, create folder.
- modify key value pairs in config file. multiple pairs separated space.
a sample snippet below:
{ "container_commands": { "01_add_tags": { "command": "aws ec2 create-tags --resources $(get http://169.254.169.254/latest/meta-data/instance-id) --tags key=clientname,value=testclient key=newtag,value=new-value --region us-east-1" } } }
- add modified config file in ".ebextensions" folder.
- upload version beanstalk. should launch new instances , execute config file.
- please give sometime, preferably till instances pass ec2 instance status checks. refresh page additional tags displayed.
please note using "container_commands" instead of "command" used in blog. container commands run after application , web server have been set , application version file has been extracted, before application version deployed. important these commands have access environment variables such aws security credentials set instance-profile.
i recommend go through restrictions aws resources tagging mentioned @ http://docs.aws.amazon.com/awsec2/latest/userguide/using_tags.html#tag-restrictions highlight maximum number of tags per resource 10.
also check table tagging support resource. example, tagging not supported elb.
Comments
Post a Comment