Skip to content
New issue

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

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

Already on GitHub? # to your account

(custom-resources): Asset for Backend Lambda Function Empty #27950

Closed
Kapral67 opened this issue Nov 12, 2023 · 3 comments
Closed

(custom-resources): Asset for Backend Lambda Function Empty #27950

Kapral67 opened this issue Nov 12, 2023 · 3 comments
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@Kapral67
Copy link

Kapral67 commented Nov 12, 2023

Describe the bug

Deploying stacks that create software.amazon.awscdk.customresources.AwsCustomResource fail because the Backend Lambda cannot be created with an empty handler zip file.

Expected Behavior

The software.amazon.awscdk.customresources.AwsCustomResource to create and deploy on cdk deploy

Current Behavior

The asset containing the handler for the lambda function backing the software.amazon.awscdk.customresources.AwsCustomResource is a zip file with an empty index.js, blocking deployment as Lambda function cannot be created with empty zip:

Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400

Reproduction Steps

Create a stack that creates some software.amazon.awscdk.customresources.AwsCustomResource and attempt to deploy (or just run cdk synth and see if the asset's (in cdk.out) index.js is empty or not)

E.g.:

import java.util.Collections;
import java.util.List;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.customresources.AwsCustomResource;
import software.amazon.awscdk.customresources.AwsCustomResourcePolicy;
import software.amazon.awscdk.customresources.AwsCustomResourceProps;
import software.amazon.awscdk.customresources.AwsSdkCall;
import software.amazon.awscdk.customresources.PhysicalResourceId;
import software.amazon.awscdk.services.iam.Effect;
import software.amazon.awscdk.services.iam.PolicyStatement;
import software.constructs.Construct;

public
class PlaygroundStack extends Stack {
    public
    PlaygroundStack (final Construct scope, final String id, final StackProps stackProps) {
        super(scope, id, stackProps);

        final AwsSdkCall awsSdkCall = AwsSdkCall.builder()
                                                .service("SSM")
                                                .action("getParameter")
                                                .parameters(Collections.singletonMap("Name", "SOME_EXISTING_PARAMETER_NAME"))
                                                .physicalResourceId(PhysicalResourceId.of("SOME_PHYSICAL_RESOURCE_ID"))
                                                .region("SOME_AWS_REGION")
                                                .build();

        final List<PolicyStatement> policyStatements = Collections.singletonList(PolicyStatement.Builder.create()
                                                                                                        .actions(Collections.singletonList("ssm:GetParameter"))
                                                                                                        .effect(Effect.ALLOW)
                                                                                                        .resources(Collections.singletonList("*"))
                                                                                                        .build());

        final AwsCustomResourcePolicy awsCustomResourcePolicy = AwsCustomResourcePolicy.fromStatements(policyStatements);

        final AwsCustomResourceProps awsCustomResourceProps = AwsCustomResourceProps.builder()
                                                                                    .onCreate(awsSdkCall)
                                                                                    .onUpdate(awsSdkCall)
                                                                                    .policy(awsCustomResourcePolicy)
                                                                                    .build();

        new AwsCustomResource(this, "AwsCustomResourceId", awsCustomResourceProps);
    }
}

Possible Solution

No response

Additional Information/Context

CDK CLI Version

2.106.0

Framework Version

No response

Node.js Version

18.18.2

OS

archlinux 6.6.1-arch1-1

Language

Java

Language Version

Java ( Corretto-17.0.9.8.1 (build 17.0.9+8-LTS) )

Other information

No response

@Kapral67 Kapral67 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 12, 2023
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Nov 12, 2023
@pahud
Copy link
Contributor

pahud commented Nov 14, 2023

Are you still having this issue in 2.108.0 ?

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2023
@Kapral67
Copy link
Author

Issue not present after upgrading to 2.108.0

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants