Skip to content

Instantly share code, notes, and snippets.

@kizashi1122
Last active February 6, 2020 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kizashi1122/2ad29cff30797087c9264346cff1f8dc to your computer and use it in GitHub Desktop.
Save kizashi1122/2ad29cff30797087c9264346cff1f8dc to your computer and use it in GitHub Desktop.
chef file to attach role to itself
ey_aws_key = "retrieved from dna.json"
ey_aws_secret = "retrieved from dna.json"
bash "add engine yard user to credentials" do
user 'deploy'
code <<-"EOH"
echo '[engineyard]' >> /home/deploy/.aws/credentials
echo 'aws_access_key_id=#{ey_aws_key}' >> /home/deploy/.aws/credentials
echo 'aws_secret_access_key=#{ey_aws_secret}' >> /home/deploy/.aws/credentials
EOH
not_if "grep engineyard /home/deploy/.aws/credentials"
end
bash "install aws cli" do
user 'deploy'
code <<-EOH
curl "https://d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
EOH
not_if "aws2 --version"
end
instance_id = node[:engineyard][:this]
bash "associate a role to use KMS" do
user 'deploy'
code <<-"EOH"
aws ec2 associate-iam-instance-profile --instance-id #{instance_id} --iam-instance-profile Name=TBD --profile engineyard
EOH
not_if "aws2 ec2 describe-iam-instance-profile-associations --profile engineyard | grep <????>"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment