Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdk deploy failure in blue_green_deployments stage #18

Closed
seyfer opened this issue Oct 11, 2021 · 2 comments
Closed

cdk deploy failure in blue_green_deployments stage #18

seyfer opened this issue Oct 11, 2021 · 2 comments

Comments

@seyfer
Copy link

seyfer commented Oct 11, 2021

when I am on this page
https://ecsworkshop.com/blue_green_deployments/build_environment/

and I run

cdk deploy --require-approval never

I have this error

4:09:33 PM | CREATE_FAILED        | AWS::Lambda::Function                     | createDeploymentGroupLambda
Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: 3c34131a-fd1d-4ab8-910c-a5c5835676c1, Extended Request ID: null)" (RequestToken: de7494e8-19
4c-3c7f-0643-eb02c68208b6, HandlerErrorCode: InvalidRequest)

which is logical, because of the definition

// Custom resource to create the deployment group
        const createDeploymentGroupLambda = new lambda.Function(this, 'createDeploymentGroupLambda', {
            code: lambda.Code.fromAsset(
                path.join(__dirname, 'custom_resources'),
                {
                    exclude: ["**", "!create_deployment_group.py"]
                }),
            runtime: lambda.Runtime.PYTHON_3_8,
            handler: 'create_deployment_group.handler',
            role: customLambdaServiceRole,
            description: "Custom resource to create deployment group",
            memorySize: 128,
            timeout: cdk.Duration.seconds(60)
        });

the cloned repo directory custom_resources contains only custom_resources/create_deployment_group.py file, which is excluded by the lambda definition, therefore it attempts to upload empty zip.
is there some file missing in the demo repository in the custom_resources directory?

@senatoredu
Copy link
Contributor

@seyfer ran into this issue myself while building same same environment for B/G deployments.

Turns out this is a known issue with AWS CDK with respect to node versions, see here: aws/aws-cdk#12536

In summary when using the Code.fromAsset() API for the lambda module with local assets, deploying new assets will fail with the error that you're seeing ("Uploaded file must be a non-empty zip (Service: Lambda")).

This has confirmed behavior if you're using a node version > 15.6 and a fix is to downgrade.
I've tested v14.15.4 and was able to run the "cdk deploy" command successfully after with all components built.

Steps 2/3 call out clearing out the cache in the cdk.out/ directory (on your local IDE) and from your S3 bucket.

For step 1: downgrading the Node engine i used NVM to install v14.15.4 and uninstall v15.6, did below:

  1. confirm your node version: node --version
  2. install 14.15.4: nvm install 14.15.4
  3. uninstall 15.6: nvm uninstall 15.6
  4. reconfirm node version: node --version to be v14.15.4

After run the cdk deploy again and it should work

@adamjkeller
Copy link
Contributor

Hey all, just FYI we refreshed the Blue Green deployment chapter and just merged the changes this week. Hopefully the experience will be much better now. Thanks for bringing this up and thank you @senatoredu for the assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants