Skip to content

Commit

Permalink
Merge branch 'master' into feature/timeout-option-helm-charts
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel authored Jun 11, 2020
2 parents 87f8c5b + f10da03 commit 811420a
Show file tree
Hide file tree
Showing 10 changed files with 468 additions and 79 deletions.
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-amplify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ const amplifyApp = new amplify.App(this, 'MyApp', {
});
```

To connect your `App` to GitLab, use the `GitLabSourceCodeProvider`:
```ts
const amplifyApp = new amplify.App(this, 'MyApp', {
sourceCodeProvider: new amplify.GitLabSourceCodeProvider({
owner: '<user>',
repository: '<repo>',
oauthToken: cdk.SecretValue.secretsManager('my-gitlab-token')
})
});
```

To connect your `App` to CodeCommit, use the `CodeCommitSourceCodeProvider`:
```ts
const repository = new codecommit.Repository(this, 'Repo', {
Expand Down
34 changes: 34 additions & 0 deletions packages/@aws-cdk/aws-amplify/lib/source-code-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,40 @@ export class GitHubSourceCodeProvider implements ISourceCodeProvider {
}
}

/**
* Properties for a GitLab source code provider
*/
export interface GitLabSourceCodeProviderProps {
/**
* The user or organization owning the repository
*/
readonly owner: string;

/**
* The name of the repository
*/
readonly repository: string;

/**
* A personal access token with the `repo` scope
*/
readonly oauthToken: SecretValue;
}

/**
* GitLab source code provider
*/
export class GitLabSourceCodeProvider implements ISourceCodeProvider {
constructor(private readonly props: GitLabSourceCodeProviderProps) { }

public bind(_app: App): SourceCodeProviderConfig {
return {
repository: `https://gitlab.com/${this.props.owner}/${this.props.repository}`,
oauthToken: this.props.oauthToken,
};
}
}

/**
* Properties for a CodeCommit source code provider
*/
Expand Down
52 changes: 52 additions & 0 deletions packages/@aws-cdk/aws-amplify/test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,58 @@ test('create an app connected to a GitHub repository', () => {
});
});

test('create an app connected to a GitLab repository', () => {
// WHEN
new amplify.App(stack, 'App', {
sourceCodeProvider: new amplify.GitLabSourceCodeProvider({
owner: 'aws',
repository: 'aws-cdk',
oauthToken: SecretValue.plainText('secret'),
}),
buildSpec: codebuild.BuildSpec.fromObject({
version: '1.0',
frontend: {
phases: {
build: {
commands: [
'npm run build',
],
},
},
},
}),
});

// THEN
expect(stack).toHaveResource('AWS::Amplify::App', {
Name: 'App',
BuildSpec: '{\n \"version\": \"1.0\",\n \"frontend\": {\n \"phases\": {\n \"build\": {\n \"commands\": [\n \"npm run build\"\n ]\n }\n }\n }\n}',
IAMServiceRole: {
'Fn::GetAtt': [
'AppRole1AF9B530',
'Arn',
],
},
OauthToken: 'secret',
Repository: 'https://gitlab.com/aws/aws-cdk',
});

expect(stack).toHaveResource('AWS::IAM::Role', {
AssumeRolePolicyDocument: {
Statement: [
{
Action: 'sts:AssumeRole',
Effect: 'Allow',
Principal: {
Service: 'amplify.amazonaws.com',
},
},
],
Version: '2012-10-17',
},
});
});

test('create an app connected to a CodeCommit repository', () => {
// WHEN
new amplify.App(stack, 'App', {
Expand Down
11 changes: 7 additions & 4 deletions packages/@aws-cdk/aws-appsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ export class ApiStack extends Stack {
},
authorizationConfig: {
defaultAuthorization: {
userPool,
defaultAction: UserPoolDefaultAction.ALLOW,
authorizationType: AuthorizationType.USER_POOL,
userPoolConfig: {
userPool,
defaultAction: UserPoolDefaultAction.ALLOW
},
},
additionalAuthorizationModes: [
{
apiKeyDesc: 'My API Key',
},
authorizationType: AuthorizationType.API_KEY,
}
],
},
schemaDefinitionFile: './schema.graphql',
Expand Down
Loading

0 comments on commit 811420a

Please sign in to comment.