Skip to content

(Amazon.CDK.AWS.CloudFront.Experimental): Stack fails to publish when edge function is included #16832

@Mike-Gilge

Description

@Mike-Gilge

What is the problem?

When I try to publish my stack with an EdgeFunction it is failing on the outputted ssm parameter. Nothing I have tried makes any difference.

Reproduction Steps

           CloudFrontDistribution = new Distribution(this, "Work Remote Cloudfront distribution", new DistributionProps
           {
               DefaultBehavior = new BehaviorOptions
               {
                   Origin = new S3Origin(WebsiteBucket),
                   ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
                   EdgeLambdas = new IEdgeLambda[]{new EdgeLambda
                   {
                       EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
                       IncludeBody = true,
                       FunctionVersion = new EdgeFunction(this, "AWS MarketplaceRedirect", new EdgeFunctionProps
                       {
                           FunctionName = "AwsMarketplaceRedirect",
                           Runtime = Runtime.NODEJS_12_X,
                           Code = Code.FromAsset("src/VegaWorkRemoteBackendStack"),
                           Handler = "AwsMarketplaceRedirect.lambdaHandler",
                       }).CurrentVersion
                   }}
               },
               //This allows spa to function correctly
               ErrorResponses = new IErrorResponse[]{new ErrorResponse
               {
                   HttpStatus = 404,
                   Ttl = Duration.Seconds(0),
                   ResponsePagePath = "/index.html",
                   ResponseHttpStatus = 200
               }},
           });

What did you expect to happen?

I would expect the stack to publish and for a lambda edge to be set up with CloudFront.

What actually happened?

4/6 | 3:37:08 PM | CREATE_IN_PROGRESS   | AWS::SSM::Parameter   | AWS MarketplaceRedirect/Parameter (AWSMarketplaceRedirectParameter9203C56D) 
 4/6 | 3:37:09 PM | CREATE_FAILED        | AWS::SSM::Parameter   | AWS MarketplaceRedirect/Parameter (AWSMarketplaceRedirectParameter9203C56D) Parameter name: can't be prefixed with "ssm" (case-insensitive). If formed as a path, it can consist of sub-paths divided by slash symbol; each sub-path can be formed as a mix of letters, numbers and the following 3 symbols .-_ (Service: AmazonSSM; Status Code: 400; Error Code: ValidationException; Request ID: 211ea5fc-b166-4569-b713-41ac6b123518; Proxy: null)
   new StringParameter (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/jsii-kernel-3vSJaz/node_modules/@aws-cdk/aws-ssm/lib/parameter.js:98:26)
   \_ EdgeFunction.createCrossRegionFunction (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/jsii-kernel-3vSJaz/node_modules/@aws-cdk/aws-cloudfront/lib/experimental/edge-function.js:229:9)
   \_ new EdgeFunction (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/jsii-kernel-3vSJaz/node_modules/@aws-cdk/aws-cloudfront/lib/experimental/edge-function.js:41:20)
   \_ /private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:8432:58
   \_ Kernel._wrapSandboxCode (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:8860:24)
   \_ Kernel._create (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:8432:34)
   \_ Kernel.create (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:8173:29)
   \_ KernelHost.processRequest (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:9757:36)
   \_ KernelHost.run (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:9720:22)
   \_ Immediate._onImmediate (/private/var/folders/3v/9ls13tw104s2vyzzyzbsggh80000gn/T/trhycroh.fhm/lib/program.js:9721:46)
   \_ processImmediate (internal/timers.js:464:21)
 4/6 | 3:37:10 PM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | edge-lambda-stack-c8a3e34b082c95e9bff7304ce956ae2ceb3b1462d1 The following resource(s) failed to create: [AWSMarketplaceRedirectParameter9203C56D]. Rollback requested by user.

CDK CLI Version

1.126.0

Framework Version

No response

Node.js Version

v14.17.1

OS

Mac OS 11.6

Language

.NET

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cloudfrontRelated to Amazon CloudFrontbugThis issue is a bug.effort/smallSmall work item – less than a day of effortin-progressThis issue is being actively worked on.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions