Open anacunha opened 1 year ago
Hey @anacunha :wave: thanks for raising this and apologies for the delay! I will mark this as a feature request for the CDK construct to enforce the same constraints as the CLI
? Enter a name for the environment reallylongenvironmentname
>> Environment name must be between 2 and 10 characters, and lowercase only.
Note for fix, use constraints from Amplify CLI here https://github.com/aws-amplify/amplify-cli-export-construct/blob/main/src/export-backend.ts#L50
amplifyEnvironment
does not adhere to constraints
Before opening, please confirm:
How did you install the Amplify CLI?
npm install -g @aws-amplify/cli
If applicable, what version of Node.js are you using?
v16.14.2
Amplify CLI Version
10.5.1
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No changes were made.
Amplify Categories
auth, api
Amplify Commands
export
Describe the bug
An exported Amplify app fails deployment with CDK due to IAM role names with more than 64 characters.
region + accountId
as theamplifyEnvironment
following the Amplify documentation for cross-account deployments)CloudFormation stack fails due to the following errors:
1 validation error detected: Value 'AmplifyDataStoreIAMRb752cd-47fjl5efbrcl7nqvratjod2dwy-us-west-2558501674497' at 'roleName' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: AmazonIdentityManagement; Status Code: 400; Error Code: ValidationError; Request ID: a7cdeb23-c484-4932-8a24-035f09803c51; Proxy: null)
1 validation error detected: Value 'CardIAMRole189df4-47fjl5efbrcl7nqvratjod2dwy-us-west-2558501674497' at 'roleName' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: AmazonIdentityManagement; Status Code: 400; Error Code: ValidationError; Request ID: e789091f-c5ef-4b26-a138-0f711b7b458c; Proxy: null)
Expected behavior
Expected the exported version of the Amplify app backend to be successfully deployed with CDK.
Reproduction steps
Amplify App
npx create-react-app@latest flashcards
amplify init
npm install aws-amplify
amplify add auth
amplify push
amplify add api
amplify/backend/api/flashcards/schema.graphql
to reflect schema belowamplify push
amplify export --out ../<cdk-project>/lib
CDK Project
npx cdk@1 init app --language=typescript
npm i @aws-amplify/cdk-exported-backend@0.0.5
/bin/flashcards-infra-v1.ts
file:/lib/flashcards-infra-v1-stack.ts
file:cdk deploy --all
GraphQL schema(s)
Project Identifier
1976cbf2edefcf064c89a92d41898045
Log output
Additional information
Problem persists with any combination of:
aws-cdk
: version 1.177.0 /@aws-amplify/cdk-exported-backend
: version 0.0.5aws-cdk
: version 2.51.1 /@aws-amplify/cdk-exported-backend
: version 0.0.6Changing the
AmplifyExportedBackend
amplifyEnvironment
prop to something shorter (e.g.prod
) allows deployment of the Amplify backend to succeed