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

Types incompatible issue when trying to execute amplify pull command #13440

Closed
2 tasks done
deepak-donde opened this issue Nov 30, 2023 · 9 comments
Closed
2 tasks done
Labels
custom-cdk Issues related to custom CDK resource functionality pending-triage Issue is pending triage

Comments

@deepak-donde
Copy link

deepak-donde commented Nov 30, 2023

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

18.16.0

Amplify CLI Version

12.1.1

What operating system are you using?

Ubuntu

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

I have to work on existing amplify project so I followed below steps:

  1. git clone (link to project)
  2. npm i
  3. npm install -g @aws-amplify/cli
  4. amplify configure
  5. amplify pull --appId (your app id) --envName (env name)

After execution of step 5, I get multiple issues related to aws-cdk compatibility in path /amplify/backend/custom/example/
e.g.

Types of parameters 'grantee' and 'grantee' are incompatible
Types of parameters 'statement' and 'statement' are incompatible.
Types of property 'next' are incompatible
Types of parameters 'state' and 'state' are incompatible.
The types of 'startState.endStates' are incompatible between these types.

I am able to resolve this issue on local environment by setting aws-cdk version to 1.172.0 in package.json in /amplify/backend/custom/example/
BUT
When i execute amplify pull it overrides aws-cdk version to 1.81.0 which causes incompatible issue.
Because of this i am not able to pull amplify project.

Is there anyway to prevent aws-cdk version override from amplify pull command?
or is there any way to update this version on AWS console and then execute amplify pull command?

Expected behavior

There should be a way to update dependencies version on AWS console for the resources created by amplify add custom command

Reproduction steps

This is an existing project on which i configure amplify and executed amplify pull command

Project Identifier

No response

Log output

# Put your logs below this line

⠧ Fetching updates to backend environment: dev from the cloud.🛑 Failed building resource courseUnlockStep
✖ Fetching updates to backend environment: dev from the cloud.
✖ There was an error initializing your environment.
🛑 There was an error building the custom resources
Command failed with exit code 2: /node_modules/.bin/tsc
cdk-stack.ts(51,7): error TS2322: Type 'import("/node_modules/@aws-cdk/aws-lambda/lib/function-base").IFunction' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-lambda/lib/function-base").IFunction'.
  The types of 'role.grant' are incompatible between these types.
    Type '(grantee: import("/node_modules/@aws-cdk/aws-iam/lib/principals").IPrincipal, ...actions: string[]) => import("/node_modules/@aws-cdk/aws-iam/lib/grant").Grant' is not assignable to type '(grantee: import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-iam/lib/principals").IPrincipal, ...actions: string[]) => import("/n...'.
      Types of parameters 'grantee' and 'grantee' are incompatible.
        Type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-iam/lib/principals").IPrincipal' is not assignable to type 'import("/node_modules/@aws-cdk/aws-iam/lib/principals").IPrincipal'.
          Types of property 'addToPolicy' are incompatible.
            Type '(statement: import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-iam/lib/policy-statement").PolicyStatement) => boolean' is not assignable to type '(statement: import("/node_modules/@aws-cdk/aws-iam/lib/policy-statement").PolicyStatement) => boolean'.
              Types of parameters 'statement' and 'statement' are incompatible.
                Type 'import("/node_modules/@aws-cdk/aws-iam/lib/policy-statement").PolicyStatement' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-iam/lib/policy-statement").PolicyStatement'.
                  Types have separate declarations of a private property '_action'.
cdk-stack.ts(55,29): error TS2345: Argument of type 'LambdaInvoke' is not assignable to parameter of type 'IChainable'.
  The types of 'startState.endStates' are incompatible between these types.
    Type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable[]' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable[]'.
      Type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable'.
        Types of property 'next' are incompatible.
          Type '(state: import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/types").IChainable) => import("/node_modules/@aws-cd...' is not assignable to type '(state: import("/node_modules/@aws-cdk/aws-stepfunctions/lib/types").IChainable) => import("/node_modules/@aws-cdk/aws-stepfunctions/lib/chain").Chain'.
            Types of parameters 'state' and 'state' are incompatible.
              Type 'import("/node_modules/@aws-cdk/aws-stepfunctions/lib/types").IChainable' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/types").IChainable'.
                The types of 'startState.endStates' are incompatible between these types.
                  Type 'import("/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable[]' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable[]'.
                    Type 'import("/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/types").INextable'.
                      The types returned by 'next(...)' are incompatible between these types.
                        Type 'import("/node_modules/@aws-cdk/aws-stepfunctions/lib/chain").Chain' is not assignable to type 'import("/node_modules/@aws-cdk/aws-stepfunctions-tasks/node_modules/@aws-cdk/aws-stepfunctions/lib/chain").Chain'.
                          Types have separate declarations of a private property 'lastAdded'.

Resolution: There may be errors in your custom resource file. If so, fix the errors and try again.
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Session Identifier: 0bd441ce-d875-4aca-962b-8c5893a27913



Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@deepak-donde deepak-donde added the pending-triage Issue is pending triage label Nov 30, 2023
@AkshayBalasahebTalole
Copy link

@deepak-donde I'm facing the same issue while using below stepfunction code . Used @aws-cdk/aws-stepfunctions-tasks package with 1.181.0 version.

const lambdaTask = new tasks.LambdaInvoke(this, 'unlock_lambda', {
  lambdaFunction: lamdafunction,
})

const stateMachine = new sfn.StateMachine(this, 'NameStateMachine', {
  definition: wait.next(lambdaTask),
  role: serviceRole
});

@deepak-donde deepak-donde changed the title Types incompatible issue when trying to execute amplify pull commad Types incompatible issue when trying to execute amplify pull command Nov 30, 2023
@ykethan
Copy link
Member

ykethan commented Nov 30, 2023

Hey @deepak-donde, thank you for reaching out. You will need to ensure the aws-cdk-lib version matches the version used by the extensibility package

@ykethan ykethan added pending-response Issue is pending response from the issue author custom-cdk Issues related to custom CDK resource functionality labels Nov 30, 2023
@deepak-donde
Copy link
Author

@ykethan Thanks for the response. I can resolve version mismatch error only after successful pull operation which is failing at this moment.
Also, current implementation uses aws-cdk not aws-cdk-lib. The migration is planned in later stage But first I need to setup amplify project.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Dec 1, 2023
@ykethan
Copy link
Member

ykethan commented Dec 1, 2023

@deepak-donde thank you for the info, tried reproducing the issue by creating a project with an older version of Amplify CLI(10.5.0) then pulling the app using the newer version of CLI(12.1.1) in a empty folder but did not observe this error message.
While I work on reproducing this, could you try downgrading the Amplify CLI version then running pull to check if this mitigates the behaviour, then upgrade the CLI version and migrate the resources.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Dec 1, 2023
@ykethan
Copy link
Member

ykethan commented Dec 4, 2023

@deepak-donde on conferring with the team, I was able to find that we should be able to upgrade/modify the cdk version after the amplify pull --appId <app-id> --envName <env-name> and run push which should update the deployment bucket. The consequent pull should not replace the custom resource, as the pull retrieves the backend and builds the resource locally.

@deepak-donde
Copy link
Author

deepak-donde commented Dec 5, 2023

@ykethan amplify pull --appId <app-id> --envName <env-name> is overriding aws-cdk version from 1.172.0 to 1.181.0 in path /amplify/backend/custom/example/package.json and then gives error log output.

I think this problem will be solved once we get to know where the aws-cdk version is located on AWS console and if we can update it for custom resources( resources added by using command amplify add custom)

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Dec 5, 2023
@ykethan
Copy link
Member

ykethan commented Dec 5, 2023

@deepak-donde to prevent any misunderstanding, amplify pull --appId <app-id> --envName <env-name> pulls the resources from current-cloud-backend.zip present in the S3 deployment bucket.
Could you please try running the following.

  1. amplify pull --appId <app-id> --envName <env-name> in a empty folder, this will pull the current-cloud-backend and try to build the cdk resource locally. we run into the mismatch error in the local build.
  2. to update the cdk version locally, open the custom resource and modify the package.json file containing cdk package and the construct.
  3. amplify push , this will ensure the current-cloud-backend in s3 deployment bucket is updated with the cdk version.
  4. then run amplify pull to ensure the local version is not being overridden and synced.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Dec 5, 2023
@deepak-donde
Copy link
Author

deepak-donde commented Jan 24, 2024

I was able to resolve this issue by following below steps:

  1. Asked the main developer(who has existing setup on his machine) settingaws-cdkversion to 1.172.0 in package.json in /amplify/backend/custom/example/
  2. git clone (link to project)
  3. npm i
  4. npm install -g @aws-amplify/cli
  5. amplify configure
  6. amplify pull --appId (your app id) --envName (env name)
    step 6 does not override aws-cdk in this case and setup completed with success message.

Step 1 is not ideal case if you don't have access to developer who has successfully build the code

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Jan 24, 2024
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom-cdk Issues related to custom CDK resource functionality pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

3 participants