Skip to content

Commit

Permalink
- Fixed codedeploy launch bundle.
Browse files Browse the repository at this point in the history
- added ec2lm_replace_secret_in_file_from_json() function to EC2LM
  • Loading branch information
gitwater committed Jul 20, 2021
1 parent 96d729a commit 42b33f6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/paco/application/ec2_launch_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,17 @@ def add_secrets_function_policy(self, resource):
sed -i -e "s/$SED_PATTERN/$SECRET/" $REPLACE_FILE
}
# ec2lm_replace_secret_in_file_from_json <secret id> <file> <replace pattern> <secret name>
function ec2lm_replace_secret_in_file_from_json() {
SECRET_ID=$1
SED_PATTERN=$2
REPLACE_FILE=$3
SECRET_KEY=$4
SECRET_JSON=$(ec2lm_get_secret $SECRET_ID)
SECRET=$(echo $SECRET_JSON | jq -r ".${SECRET_KEY}")
sed -i -e "s/$SED_PATTERN/$(sed_escape $SECRET)/" $REPLACE_FILE
}
"""
iam_policy_name = '-'.join([resource.name, 'secrets'])
template_params = []
Expand Down Expand Up @@ -2127,20 +2138,22 @@ def lb_add_codedeploy(self, bundle_name, resource):
cd /tmp/
ec2lm_install_wget
ec2lm_install_package ruby
# Stopping the current agent
echo "EC2LM: CodeDeploy: Stopping the agent"
stop_agent
echo "EC2LM: CodeDeploy: Downloading Agent"
rm -f install
wget https://aws-codedeploy-ca-central-1.s3.amazonaws.com/latest/install
chmod u+x ./install
# Stopping the current agent
stop_agent
echo "EC2LM: CodeDeploy: Installing Agent"
./install auto
CODEDEPLOY_AGENT_CONF="/etc/codedeploy-agent/conf/codedeployagent.yml"
grep -v max_revisions $CODEDEPLOY_AGENT_CONF >$CODEDEPLOY_AGENT_CONF.new
echo ":max_revisions: 1" >>$CODEDEPLOY_AGENT_CONF.new
mv $CODEDEPLOY_AGENT_CONF.new $CODEDEPLOY_AGENT_CONF
service codedeploy-agent start
service codedeploy-agent restart
echo
echo "EC2LM: CodeDeploy: Agent install complete."
Expand Down

0 comments on commit 42b33f6

Please sign in to comment.