-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(cloud9): support AWS CodeCommit repository clone on launch #8205
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Thanks for the contribution @pahud ! Looks good, some minor comments (and one important question) below.
Co-authored-by: Adam Ruka <adamruka85@gmail.com>
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
@skinny85 This mostly LGTM. Please check this out.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@pahud before I review, I want to understand something first. Do you not need any permissions on the CodeCommit repo that you're cloning? Did you try and spin up a new Cloud9 environment with this functionality, and was the repository cloned correctly? |
Yes. I have run two tests: The first one is to create a new codecommit repo and cloud9 environment in the same stack, which is exactly what my integ test does import * as codecommit from '@aws-cdk/aws-codecommit';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import * as cloud9 from '../lib';
export class Cloud9Env extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'VPC', {
maxAzs: 2,
natGateways: 1,
});
// create a codecommit repository to clone into the cloud9 environment
const repo = new codecommit.Repository(this, 'Repo', {
repositoryName: 'foo',
});
// create a cloud9 ec2 environment in a new VPC
const c9env = new cloud9.Ec2Environment(this, 'C9Env', {
vpc,
// clone repositories into the environment
clonedRepositories: [
cloud9.CloneRepository.fromCodeCommit(repo, '/foo'),
],
});
new cdk.CfnOutput(this, 'URL', { value: c9env.ideUrl });
new cdk.CfnOutput(this, 'ARN', { value: c9env.ec2EnvironmentArn });
}
}
const app = new cdk.App();
new Cloud9Env(app, 'C9Stack'); The c9 environment and codecommit repo all created correctly and when I click the cloud9 URL: It just cloned the new codecommit repo into the target path I specified, though the repo is empty I still can see the Another test is to create a new cloud9 environment and clone an existing codecommit repository which I created manually. // import an existing codecommit repo
const repo = codecommit.Repository.fromRepositoryName(this, 'Repo', 'wildrydes-site');
const c9env = new cloud9.Ec2Environment(this, 'C9Env', {
vpc,
// clone repositories into the environment
clonedRepositories: [
cloud9.CloneRepository.fromCodeCommit(repo, '/foo'),
],
}); To make it clear, I just updated the README with this sample: Cloning RepositoriesUse // create a codecommit repository to clone into the cloud9 environment
const repoNew = new codecommit.Repository(this, 'RepoNew', {
repositoryName: 'new-repo',
});
// import an existing codecommit repository to clone into the cloud9 environment
const repoExisting = codecommit.Repository.fromRepositoryName(stack, 'RepoExisting', 'existing-repo');
// create a new Cloud9 environment and clone the two repositories
new cloud9.Ec2Environment(stack, 'C9Env', {
vpc,
clonedRepositories: [
cloud9.CloneRepository.fromCodeCommit(repoNew, '/src/new-repo'),
cloud9.CloneRepository.fromCodeCommit(repoExisting, '/src/existing-repo'),
],
}); And both repos were cloned correctly as expected: |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Thanks for the great contribution @pahud !
* | ||
* @default - do not clone any repository | ||
*/ | ||
// readonly clonedRepositories?: Cloud9Repository[]; |
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.
No need for this commented out line anymore.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
feat(cloud9): support AWS CodeCommit repository clone on launch
Add a new
repositories
property to allow users to clone AWS CodeCommit repositories on environment launch.Closes #8204
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license