CodeCommit Repository Creation: Automated Initialization and Template Integration

Designing an Approach for Automated Initialization of CodeCommit Repositories

Prev Question Next Question

Question

A big IT company started using AWS CodeCommit to manage its source code.

There are hundreds of developers and new Git repositories are added in CodeCommit frequently.

The DevOps team was told to design an approach to create a new repository by running a script and after the script has run, some init code such as template and README can be added into the repository automatically.

Which approach is the best to be managed?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - B.

AWS CodeCommit supports including code when creating a repository with AWS CloudFormation.

Check the document in.

https://aws.amazon.com/about-aws/whats-new/2019/05/aws-codecommit-now-supports-the-ability-to-make-an-initial-commit/.

Option A is incorrect: The question asks for a solution that can be easily managed.This option is not as good as Option.

B.Option B is CORRECT: CloudFormation stack can be easily managed.

The stack can configure a new repository and in the meantime, add the application code into the new created repository.

Option C is incorrect: Because CloudFormation can already achieve the requirement.

There is no need to use Lambda function.

Option D is incorrect: Refer to the above link.

The best approach for creating a new repository with init code in AWS CodeCommit is to use a CloudFormation template with a Lambda function to add the initial code to the repository.

Option A: Design a shell script using Git commands to create a new repository and submit the init code. This approach may work, but it would require developers to have access to the shell script and execute it properly, which could lead to inconsistencies and errors. Additionally, it would be difficult to manage and update the script as the number of repositories grows.

Option B: Put the code into an S3 bucket. Design a CloudFormation template to create a repository with the resource type AWS::CodeCommit::Repository. Add a property to include the code. Create a CloudFormation stack when needed. This approach could work, but it would require developers to manually create a CloudFormation stack every time they need a new repository, which is not ideal. Additionally, managing the code in the S3 bucket could be difficult and lead to inconsistencies.

Option C: Design a CloudFormation template to create a repository with the resource type AWS::CodeCommit::Repository. Design a Lambda function to commit the initial code to the new repository. This is the best approach. The CloudFormation template can be used to create new repositories with the necessary permissions and settings, while the Lambda function can be triggered after the repository is created to add the initial code automatically. This approach is scalable and automated, making it easy to manage as the number of repositories grows.

Option D: CodeCommit does not support this. Use GitHub instead. This is not a valid option since CodeCommit does support this functionality with the CloudFormation and Lambda approach described in Option C.

Therefore, the correct answer is option C.