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

[custom-resources][aws-codepipeline] CustomResources AssetParameters not set during Cloudformation Deploy #11415

Closed
joa44741 opened this issue Nov 11, 2020 · 7 comments
Assignees
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline @aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@joa44741
Copy link

joa44741 commented Nov 11, 2020

Description of the bug:

I try to add a custom resource to the CI/CD pipeline which I built exactly like described in this link: https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html

Reproduction Steps

add these lines to the lambda-stack.ts of the example code: https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html

import * as customres from '@aws-cdk/custom-resources';
...
const provider = new customres.Provider(this, 'mycustomprovider', { onEventHandler: alias });
new core.CustomResource(this, 'mycustomresource', { serviceToken: provider.serviceToken });

What did you expect to happen?

The CodePipeline should add the CustomResource (call the Lambda) in the CloudFormation deploy step.

What actually happened?

This error occured in the deploy step:

Parameters: [AssetParametersc691172cdeefa2c91b5a2907f9d81118e47597634943344795f1a844192dd49cS3BucketEAC9DD43, AssetParametersc691172cdeefa2c91b5a2907f9d81118e47597634943344795f1a844192dd49cS3VersionKeyDD9AE9E7, AssetParametersc691172cdeefa2c91b5a2907f9d81118e47597634943344795f1a844192dd49cArtifactHash627DAAA7] must have values (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: e8f9a97f-fee8-48e3-a182-30bf6aa6e2fd)

Environment

  • CDK CLI Version : 1.72.0
  • Framework Version: 1.72.0
  • Node.js Version: I guess the one used by codebuild.LinuxBuildImage.STANDARD_2_0
  • OS : codebuild.LinuxBuildImage.STANDARD_2_0
  • Language (Version): TypeScript (3.9.7)

Other

The same error occurs when using AwsCustomResource

new customresources.AwsCustomResource(this, CustomThingType, {`
      onCreate: {
        service: 'Iot',
        action: 'createThingType',
        parameters: {
          thingTypeName: thingType,
          thingTypeProperties: {
            searchableAttributes: [
              'status'
            ]
          }
        },
        physicalResourceId: customresources.PhysicalResourceId.fromResponse('VerificationToken') 
      },
      policy: customresources.AwsCustomResourcePolicy.fromSdkCalls({resources: customresources.AwsCustomResourcePolicy.ANY_RESOURCE})
    });

This is 🐛 Bug Report

@joa44741 joa44741 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 11, 2020
@github-actions github-actions bot added @aws-cdk/aws-codepipeline Related to AWS CodePipeline @aws-cdk/custom-resources Related to AWS CDK Custom Resources labels Nov 11, 2020
@skinny85
Copy link
Contributor

Hi @joa44741 ,

thanks for opening the issue. The reason you're seeing that error is because the custom resources use Assets, which are not compatible with that article you quoted (that's why the article uses Code.fromCfnParameters(), instead of Assets, for the Lambda code).

I would recommend you take a look at the CDK Pipelines module, which does correctly support Assets.

Thanks,
Adam

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 12, 2020
@joa44741
Copy link
Author

Hi @skinny85
Thanks for your fast response.
I also thought about using CDK Pipelines but I saw this limitation:
No context queries: context queries are not supported. That means that Vpc.fromLookup() and other functions like it will not work #8905.

How would I use an existing VPC in this case, e.g. to create a new Security Group in this Pipeline?

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 12, 2020
@skinny85
Copy link
Contributor

Hi @joa44741 ,

there is a way to work around that limitation. You need to run cdk synth with the AWS credentials of the account the VPC is in. That will populate the cdk.context.json file with the VPC information. After you git push that file, CDK will use that information instead of doing a lookup, and the pipeline build will succeed.

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 12, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Nov 16, 2020
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 20, 2020
@OperationalFallacy
Copy link

Hey @skinny85, is there a way to deploy pipeline stack with cdk.context.json?
I have context populated with cdk synth, but it doesn't add vpc/subnet info when the pipeline stack is deployed.
Which in turn makes pipeline on synth step because there is no VPC and no Internet access.

@skinny85
Copy link
Contributor

skinny85 commented Mar 1, 2021

I have context populated with cdk synth, but it doesn't add vpc/subnet info when the pipeline stack is deployed

Can you clarify @OperationalFallacy what does this mean? Why are the VPC/Subnets not populated in the cdk.context.json file for the pipeline Stack?

@OperationalFallacy
Copy link

Sorry, user error. Forgot to commit cdk.context.json in the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline @aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. 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

5 participants