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

AWS Amplify module with CodeCommit Repository #6818

Closed
kinbald opened this issue Mar 19, 2020 · 6 comments · Fixed by #6921
Closed

AWS Amplify module with CodeCommit Repository #6818

kinbald opened this issue Mar 19, 2020 · 6 comments · Fixed by #6921
Assignees
Labels
@aws-cdk/aws-amplify Related to AWS Amplify bug This issue is a bug. effort/small Small work item – less than a day of effort guidance Question that needs advice or information. in-progress This issue is being actively worked on. p2

Comments

@kinbald
Copy link

kinbald commented Mar 19, 2020

❓ General Issue

The Question

Hello,

With the introduction of the Amplify constructors (App, Branch, Domain), I updated my code from CfnApp to App.
I'm facing a problem with the accessToken and oauthToken parameters, they are now mandatory if you connect to a repository.

I understand this behavior when you connect to a 3rd party source provider like Github, Gitlab but what about the case of CodeCommit ?
My deployment used to work with CfnApp connected to a CodeCommit repository and no token as parameters.

Best regards,

Environment

  • CDK CLI Version: 1.30.0
  • Module Version: 1.30.0
  • OS: OSX Catalina
  • Language: TypeScript

Other information

Related code from app.ts
if (props.repository && !props.accessToken && !props.oauthToken) { throw new Error('EitheraccessTokenoroauthToken must be specified'); }

@kinbald kinbald added the needs-triage This issue or PR still needs to be triaged. label Mar 19, 2020
@SomayaB SomayaB added @aws-cdk/aws-amplify Related to AWS Amplify @aws-cdk/aws-codecommit Related to AWS CodeCommit guidance Question that needs advice or information. labels Mar 19, 2020
@skinny85 skinny85 removed the @aws-cdk/aws-codecommit Related to AWS CodeCommit label Mar 19, 2020
@skinny85 skinny85 assigned MrArnoldPalmer and unassigned skinny85 Mar 19, 2020
@MrArnoldPalmer
Copy link
Contributor

MrArnoldPalmer commented Mar 20, 2020

Hey @kinbald, so when providing a codecommit repository using CfnApp, if you no authToken and no oauthToken it still works? Do you have to give the amplify project's role access through iam?

@jogold for visibility.

@MrArnoldPalmer MrArnoldPalmer added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2020
@jogold
Copy link
Contributor

jogold commented Mar 20, 2020

@kinbald Did you maybe connect the repository manually using the console?

@MrArnoldPalmer the amplify project's role is only used when working with backends I think

@kinbald
Copy link
Author

kinbald commented Mar 20, 2020

Hey there,

I do not use the amplify console to connect the repo, I use the repository parameter of App constructor.
To understand a little bit more the bug, I tested 3 different stacks (CDK 1.30.0) :

  1. CfnApp + CfnBranch + CfnDomain WITHOUT token ✅ (Amplify build succeeded)
  2. App + Branch + Domain WITH valid accessToken ✅ (Amplify build succeeded)
  3. App + Branch + Domain WITH random string as accessToken ❌ (Amplify build failed)
    => Succeeded to clone the repo but failed at Backend step with accessDenied error.

And as you asked I create the app with this role :

const amplifyPrincipal = new iam.ServicePrincipal("amplify.amazonaws.com")
const amplifyRole = new iam.Role(this, "AmplifyConsoleRole", {
      assumedBy: amplifyPrincipal,
      managedPolicies: [
        iam.ManagedPolicy.fromAwsManagedPolicyName("AWSCodeCommitReadOnly")
      ],
      roleName: "AmplifyConsoleRole"
})

Thanking you in advance

@jogold
Copy link
Contributor

jogold commented Mar 20, 2020

2. App + Branch + Domain WITH valid accessToken

Which accessToken? How did you generate it?

I create the app with this role

Did you specify it in the 3 stacks?

but failed at Backend step with accessDenied error.

Do you have the full error message?

@kinbald
Copy link
Author

kinbald commented Mar 20, 2020

Which accessToken? How did you generate it?

Seamed to our team that the only token that could be generated would be with HTTPS GitCredential manager in our IAM account. We used the password string as accessToken as a try.

Did you specify it in the 3 stacks?

Yes, they all use this role.

Do you have the full error message?

Sure :
https://gist.github.com/kinbald/91d09f56830286b3fbc6cbadaf4161bd

@jogold
Copy link
Contributor

jogold commented Mar 20, 2020

@MrArnoldPalmer we should maybe have something like a SourceCodeProvider class with static methods for the different providers. We can start with GitHub and CodeCommit.

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Mar 25, 2020
@mergify mergify bot closed this as completed in #6921 Mar 30, 2020
mergify bot pushed a commit that referenced this issue Mar 30, 2020
feat(amplify): source code providers

Add source code providers classes for GitHub and CodeCommit that implement
a new `ISourceCodeProvider` interface.

Fixes #6818

BREAKING CHANGE: use the `sourceCodeProvider` prop to connect your app to a source
code provider. The props `repository`, `accessToken` and `oauthToken` do not exist
anymore in `AppProps`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-amplify Related to AWS Amplify bug This issue is a bug. effort/small Small work item – less than a day of effort guidance Question that needs advice or information. in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants