aws-codedeploy-agent icon indicating copy to clipboard operation
aws-codedeploy-agent copied to clipboard

Sym Links not preserved during deployment

Open bryantcj52 opened this issue 6 years ago • 24 comments

OS: Linux agent_version: OFFICIAL_1.0-1.1458_rpm

I am giving the code deploy agent a pre-zipped file uploaded to s3 for deployment which contains a number of relative symlinks a few directories deep (using zip -ry). I confirmed that the artifact is unzipped correctly on the server and all symlinks are there in the deployment-root, but during the copying of the files from the deployment-root to the app directory, the symlinks are replaced with the actual contents instead of preserving the symlink.

I believe this has to do with the use of Ruby's FileUtils.copy() instead of FileUtils.copyEntry() but have not tested the change yet.

bryantcj52 avatar Mar 23 '18 19:03 bryantcj52

@bryantcj52 is it something that happened with previous version of agent too, or did you just notice it happening with 1458?

rohkat-aws avatar Apr 18 '18 04:04 rohkat-aws

@rohkat-aws I've only tested with 1458.

bryantcj52 avatar Apr 18 '18 16:04 bryantcj52

@bryantcj52 is it possible to share a dummy zip with folder structure like this , so that we can try to reproduce this on our end?

rohkat-aws avatar Apr 18 '18 18:04 rohkat-aws

@rohkat-aws

https://www.dropbox.com/s/7u8zo64nedqp5n8/test-app.zip?dl=1

Here's a small example of the directory structure and sym links.

bryantcj52 avatar Apr 18 '18 18:04 bryantcj52

This appears to be happening with our deployments as well. We are using GitHub as our repo. Our symlinked directories are now being filled with the actual contents of the symlinked folder instead of the symlink. I'm not sure how long this has been happening, but I checked my repo to make sure that they were symlinked directories.

luciddev avatar Apr 20 '18 08:04 luciddev

@luciddev @bryantcj52 looking into this and trying to reproduce it

rohkat-aws avatar Apr 24 '18 21:04 rohkat-aws

so i did try running it using the copy entry command,but some of the tests fail too. Will need to look into them before including it in the code. @bryantcj52 @luciddev

rohkat-aws avatar May 30 '18 23:05 rohkat-aws

@rohkat-aws thanks for the update.

luciddev avatar May 31 '18 16:05 luciddev

How is this not higher priority? Why does the aws deploy push command do the same thing? Code build does this too. Why is AWS bent on destroying our intended file structure that includes symlinks?

Beanstalk doesn't do this, thankfully.

et304383 avatar Jun 19 '18 13:06 et304383

@et304383 its still a high priority and though it might seem an easy fix, its not ,because the tests after the change is breaking. So we are looking into it.

rohkat-aws avatar Jun 19 '18 17:06 rohkat-aws

This particular problem comes up for me with PHP-based applications (e.g. Drupal). Because we require scripting tools that are installed via composer in vendor/bin after the deployment is placed on the server. All composer-installed bin files are symlinks to their real scripts, but with codedeploy they're all broken.

quicksketch avatar Sep 18 '18 18:09 quicksketch

@quicksketch us too. This is the exact use case that the Code Deploy agent breaks.

We had to resort to bundling a fix symlinks script as part of our build and adding to our deployment package that in turn gets executed after the package is extracted.

et304383 avatar Sep 18 '18 18:09 et304383

This just started happening for me again.

rkulla avatar Apr 02 '19 19:04 rkulla

Any update on this? Happening to us me as well.

lemmikens avatar Apr 12 '19 04:04 lemmikens

Can we get an update on this please? Symlinks are a basic thing that loads of devs use to avoid duplicating code, this really needs to be looked at ASAP

nmarchini avatar Jul 13 '20 09:07 nmarchini

Saw this as a potential solution, but I think it breaks how the caching works...

https://forums.aws.amazon.com/thread.jspa?threadID=271667

jpswade avatar Jul 16 '20 08:07 jpswade

Still an issue in 2021.

jjmontgo avatar Mar 17 '21 14:03 jjmontgo

If you use npm > v6, it seems that npm rebuild repair symlink. That could be a good workaround.

maximepichou avatar Apr 30 '21 08:04 maximepichou

Still an issue in April 2022.

pipegris avatar Apr 18 '22 21:04 pipegris

Still an issue in June 2022

the6thBook avatar Jun 07 '22 17:06 the6thBook

So for codepipeline, if you use the full clone option (one with the meta data) of the github source, instead of the "default" option, your symlinks are preserved when you use the source in AWS CodeBuild.

the6thBook avatar Jun 08 '22 18:06 the6thBook

Still an issue in Aug 2022

lemmikens avatar Aug 02 '22 16:08 lemmikens

Are there any updates? Just crossed into this problem :/

alexahdp avatar Aug 07 '23 21:08 alexahdp

I found a workaround for a nodejs pnpm based application but should work for any kind of application : During the afterinstall phase I run the following:

rm -rf <application-path>/node_modules
cp -r /opt/codedeploy-agent/deployment-root/$DEPLOYMENT_GROUP_ID/$DEPLOYMENT_ID/deployment-archive/node_modules <application-path>

This will manually copy the directory preserving the symlinks structure. The two environment variables DEPLOYMENT_GROUP_ID and DEPLOYMENT_ID are available and documented. <application-path> is a replication (already defined in the appspec on the files section), but is required.

bwlt avatar May 29 '24 06:05 bwlt