-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(codebuild): remove oauthToken property from source #2252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import codecommit = require('@aws-cdk/aws-codecommit'); | ||
import iam = require('@aws-cdk/aws-iam'); | ||
import s3 = require('@aws-cdk/aws-s3'); | ||
import { SecretValue } from '@aws-cdk/cdk'; | ||
import { CfnProject } from './codebuild.generated'; | ||
import { Project } from './project'; | ||
|
||
|
@@ -211,13 +210,6 @@ export interface GitHubSourceProps extends GitBuildSourceProps { | |
*/ | ||
readonly repo: string; | ||
|
||
/** | ||
* The oAuthToken used to authenticate when cloning source git repo. | ||
* Note that you need to give CodeBuild permissions to your GitHub account in order for the token to work. | ||
* That is a one-time operation that can be done through the AWS Console for CodeBuild. | ||
*/ | ||
readonly oauthToken: SecretValue; | ||
|
||
/** | ||
* Whether to create a webhook that will trigger a build every time a commit is pushed to the GitHub repository. | ||
* | ||
|
@@ -239,14 +231,12 @@ export interface GitHubSourceProps extends GitBuildSourceProps { | |
export class GitHubSource extends GitBuildSource { | ||
public readonly type: SourceType = SourceType.GitHub; | ||
private readonly httpsCloneUrl: string; | ||
private readonly oauthToken: SecretValue; | ||
private readonly reportBuildStatus: boolean; | ||
private readonly webhook?: boolean; | ||
|
||
constructor(props: GitHubSourceProps) { | ||
super(props); | ||
this.httpsCloneUrl = `https://github.com/${props.owner}/${props.repo}.git`; | ||
this.oauthToken = props.oauthToken; | ||
this.webhook = props.webhook; | ||
this.reportBuildStatus = props.reportBuildStatus === undefined ? true : props.reportBuildStatus; | ||
} | ||
|
@@ -261,7 +251,6 @@ export class GitHubSource extends GitBuildSource { | |
|
||
protected toSourceProperty(): any { | ||
return { | ||
auth: { type: 'OAUTH', resource: this.oauthToken }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is correct. I believe you still need to supply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kaixiang-AWS can you confirm whether the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the PR and added an integ test against github source to make sure it can deploy. I can confirm that |
||
location: this.httpsCloneUrl, | ||
reportBuildStatus: this.reportBuildStatus, | ||
}; | ||
|
@@ -277,11 +266,6 @@ export interface GitHubEnterpriseSourceProps extends GitBuildSourceProps { | |
*/ | ||
readonly httpsCloneUrl: string; | ||
|
||
/** | ||
* The OAuth token used to authenticate when cloning the git repository. | ||
*/ | ||
readonly oauthToken: SecretValue; | ||
|
||
/** | ||
* Whether to ignore SSL errors when connecting to the repository. | ||
* | ||
|
@@ -296,19 +280,16 @@ export interface GitHubEnterpriseSourceProps extends GitBuildSourceProps { | |
export class GitHubEnterpriseSource extends GitBuildSource { | ||
public readonly type: SourceType = SourceType.GitHubEnterprise; | ||
private readonly httpsCloneUrl: string; | ||
private readonly oauthToken: SecretValue; | ||
private readonly ignoreSslErrors?: boolean; | ||
|
||
constructor(props: GitHubEnterpriseSourceProps) { | ||
super(props); | ||
this.httpsCloneUrl = props.httpsCloneUrl; | ||
this.oauthToken = props.oauthToken; | ||
this.ignoreSslErrors = props.ignoreSslErrors; | ||
} | ||
|
||
protected toSourceProperty(): any { | ||
return { | ||
auth: { type: 'OAUTH', resource: this.oauthToken }, | ||
location: this.httpsCloneUrl, | ||
insecureSsl: this.ignoreSslErrors, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"Resources": { | ||
"MyProjectRole9BBE5233": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"codebuild.", | ||
{ | ||
"Ref": "AWS::URLSuffix" | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
}, | ||
"MyProjectRoleDefaultPolicyB19B7C29": { | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":logs:", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
":", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":log-group:/aws/codebuild/", | ||
{ | ||
"Ref": "MyProject39F7B0AE" | ||
} | ||
] | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":logs:", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
":", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":log-group:/aws/codebuild/", | ||
{ | ||
"Ref": "MyProject39F7B0AE" | ||
}, | ||
":*" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "MyProjectRoleDefaultPolicyB19B7C29", | ||
"Roles": [ | ||
{ | ||
"Ref": "MyProjectRole9BBE5233" | ||
} | ||
] | ||
} | ||
}, | ||
"MyProject39F7B0AE": { | ||
"Type": "AWS::CodeBuild::Project", | ||
"Properties": { | ||
"Artifacts": { | ||
"Type": "NO_ARTIFACTS" | ||
}, | ||
"Environment": { | ||
"ComputeType": "BUILD_GENERAL1_SMALL", | ||
"Image": "aws/codebuild/standard:1.0", | ||
"PrivilegedMode": false, | ||
"Type": "LINUX_CONTAINER" | ||
}, | ||
"ServiceRole": { | ||
"Fn::GetAtt": [ | ||
"MyProjectRole9BBE5233", | ||
"Arn" | ||
] | ||
}, | ||
"Source": { | ||
"Location": "https://github.com/awslabs/aws-cdk.git", | ||
"ReportBuildStatus": false, | ||
"Type": "GITHUB" | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import codebuild = require('../lib'); | ||
|
||
class TestStack extends cdk.Stack { | ||
constructor(scope: cdk.App, id: string) { | ||
super(scope, id); | ||
|
||
const source = new codebuild.GitHubSource({ | ||
owner: 'awslabs', | ||
repo: 'aws-cdk', | ||
reportBuildStatus: false, | ||
}); | ||
new codebuild.Project(this, 'MyProject', { | ||
source | ||
}); | ||
} | ||
} | ||
|
||
const app = new cdk.App(); | ||
|
||
new TestStack(app, 'test-codebuild-github'); | ||
|
||
app.run(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to update this, you will also need to update:
https://github.com/awslabs/aws-cdk/blob/huijbers/bump-jsii/packages/@aws-cdk/aws-codebuild/lib/project.ts#L944
https://github.com/awslabs/aws-cdk/blob/huijbers/bump-jsii/packages/@aws-cdk/aws-codebuild/lib/project.ts#L625
And add a new image here:
https://github.com/awslabs/aws-cdk/blob/huijbers/bump-jsii/packages/@aws-cdk/aws-codebuild/lib/project.ts#L1026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not mentioning that in the PR. I have already pushed a commit to change the image, but forgot to update the documentation in the previous commit.
87b1ea0