awslabs / cloudfront-hosting-toolkit

CloudFront Hosting Toolkit offers the convenience of a managed frontend hosting service while retaining full control over the hosting and deployment infrastructure to make it your own.
Apache License 2.0
81 stars 3 forks source link

Bug: Validation Error Detected #12

Closed 58bits closed 3 weeks ago

58bits commented 4 weeks ago

Expected Behaviour

Successful deploy.

Current Behaviour

We were attempting to deploy a static (HTML/CSS only) website, and the deploy aborted with the following error:

❌ hosting-main-www-guthries-com-main failed: Error: The stack named hosting-main-www-guthries-com-main failed creation, it may need to be manually deleted from the AWS console: ROLLBACKCOMPLETE: 1 validation error detected: Value at 'pipeline.stages.1.member.actions.1.member.namespace' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9@-]+ (Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; Request ID: 8ad71865-afd2-4f77-9e88-4928bd3eecb7; Proxy: null) at FullCloudFormationDeployment.monitorDeployment (/usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:451:10568) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.deployStack2 [as deployStack] (/usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:454:199716) at async /usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:454:181438

We're using 'fish' shell, but also tried 'bash' shell.

AWS CLI aws-cli/2.0.17 Python/3.7.3 Linux/5.15.153.1-microsoft-standard-WSL2 botocore/2.0.0dev21

(will try upgrading)

Code snippet

`cloudfront-hosting-toolkit deploy`

Possible Solution

The problem is the 'period' or 'full stop' in our Git repo name. We regularly name our Git repos after app domains / applications etc. Like guthries.com, or www.foo.com etc., This causes the pipeline to fail with an invalid namespace name that contain the period character - which is not in this regex pattern: [A-Za-z0-9@-_]+ The cli and generated outputs need to be escaped to remove periods or special characters and replace them with the allowed characters of the regex expression. I'm guessing that maxLength should be checked as well.

Steps to Reproduce

cloudfront-hosting-toolkit init cloudfront-hosting-toolkit deploy

58bits commented 4 weeks ago

Updated our aws cli to the latest version (2.1) - but same error. Not sure if this helps, but this application was previously deployed to Amplify - although we've removed the Amplify application and associated cname entries.

58bits commented 4 weeks ago

Looked for issues that might be related here https://github.com/aws-cloudformation/cfn-lint/issues/2149 and here https://stackoverflow.com/questions/69548587/failed-to-satisfy-constraint-member-must-satisfy-regular-expression-pattern

58bits commented 4 weeks ago

I've also tried shortening the name of the stack, repo, and domain - wondering if maybe there was a maximum name length being exceeded. Also completely reset the project, removed the connectors and all configuration and started from scratch - but still received the following errror:

Failed resources: hosting-main-guthries-com-main | 1:44:39 PM | CREATEFAILED | AWS::CodePipeline::Pipeline | Hosting/PipelineInfrastructure/MyPipeline (HostingPipelineInfrastructureMyPipelineFC5FDDD0) 1 validation error detected: Value at 'pipeline.stages.1.member.actions.1.member.namespace' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9@-]+ (Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; Request ID: 2fe7698b-e14e-4dff-a169-7de448aac44c; Proxy: null)

❌ hosting-main-guthries-com-main failed: Error: The stack named hosting-main-guthries-com-main failed creation, it may need to be manually deleted from the AWS console: ROLLBACKCOMPLETE: 1 validation error detected: Value at 'pipeline.stages.1.member.actions.1.member.namespace' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9@-]+ (Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; Request ID: 2fe7698b-e14e-4dff-a169-7de448aac44c; Proxy: null) at FullCloudFormationDeployment.monitorDeployment (/usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:451:10568) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.deployStack2 [as deployStack] (/usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:454:199716) at async /usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:454:181438

❌ Deployment failed: Error: The stack named hosting-main-guthries-com-main failed creation, it may need to be manually deleted from the AWS console: ROLLBACKCOMPLETE: 1 validation error detected: Value at 'pipeline.stages.1.member.actions.1.member.namespace' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9@-]+ (Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; Request ID: 2fe7698b-e14e-4dff-a169-7de448aac44c; Proxy: null) at FullCloudFormationDeployment.monitorDeployment (/usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:451:10568) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.deployStack2 [as deployStack] (/usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:454:199716) at async /usr/lib/node_modules/@aws/cloudfront-hosting-toolkit/node_modules/aws-cdk/lib/index.js:454:181438

The stack named hosting-main-guthries-com-main failed creation, it may need to be manually deleted from the AWS console: ROLLBACKCOMPLETE: 1 validation error detected: Value at 'pipeline.stages.1.member.actions.1.member.namespace' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9@-]+ (Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; Request ID: 2fe7698b-e14e-4dff-a169-7de448aac44c; Proxy: null)

58bits commented 4 weeks ago

Okay we found it. The problem was the 'period' or 'full stop' in the Git repo. We regularly name our Git repos after app domains / applications etc. Like guthries.com, or www.foo.com etc. This caused the pipeline to fail with an invalid namespace name that contain the period character - which is not in this regex pattern: [A-Za-z0-9@-_]+

Can this be fixed? Could the repo name and resulting pipeline configuration names be escapes to replace any periods with another character?

cornelcroi commented 4 weeks ago

Hi, Thank you for creating the issue. Indeed some special characters from the repository name (as it is used to name some resources) were causing the error. I just pushed a fix and published a new version 1.1.15. Can you install the latest version and try to deploy again?

58bits commented 4 weeks ago

Hi, Thank you for creating the issue. Indeed some special characters from the repository name (as it is used to name some resources) were causing the error. I just pushed a fix and published a new version 1.1.15. Can you install the latest version and try to deploy again?

Hi @cornelcroi - thanks! I'll try again and report back tomorrow (it's late here - UTC + 7)

58bits commented 3 weeks ago

@cornelcroi - I can confirm that the fix worked. I was able to create and deploy a new configuration for a github repo that contained periods / full stops in the name of the repo. Thanks!