Skip to content

Instantly share code, notes, and snippets.

@WhiteyDude
Last active July 25, 2020 13:34
Show Gist options
  • Save WhiteyDude/fd8744440a021b3bb2d1b6cb40ff93ac to your computer and use it in GitHub Desktop.
Save WhiteyDude/fd8744440a021b3bb2d1b6cb40ff93ac to your computer and use it in GitHub Desktop.
CodeDeploy ruby 2.5+ non empty directories fix
files:
- source: files/codedeploy_install_instruction.patch
destination: /tmp
hooks:
AfterInstall:
- location: scripts/patch_codedeploy_and_restart.sh
timeout: 300
runas: root
212,215c212,215
< # TODO (AWSGLUE-713): handle the exception if the directory is non-empty;
< # this might mean the customer has put files in this directory and we should
< # probably ignore the error and move on
< FileUtils.rmdir(@file_path)
---
> begin
> FileUtils.rmdir(@file_path)
> rescue Errno::ENOTEMPTY
> end
#!/bin/bash
patch /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/install_instruction.rb /tmp/codedeploy_install_instruction.patch
systemctl restart amazon-cloudwatch-agent.service
@WhiteyDude
Copy link
Author

Replication of already accepted PR (aws/aws-codedeploy-agent#201) which unfortunately hasn't been added to AWS official release yet.

This is a workaround until that PR hits official release for people running > ruby 2.5 as opposed to the Amazon Linux 2 default of 2.0.0 (yuck).

Could move script to BeforeInstall most likely if you have issues on first run like some people have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment