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

Added CodeStar Conections Functionality (Git) #85

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion deployment/custom-control-tower-initiation.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Parameters:
Description: Which AWS CodePipeline source provider do you want to select?
AllowedValues:
- 'Amazon S3'
- 'GitHub'
- 'GitHubEnterpriseServer'
- 'Bitbucket'
- 'AWS CodeCommit'
Default: 'Amazon S3'
Type: String
Expand All @@ -46,6 +49,16 @@ Parameters:
Default: main
Type: String

GitRepositoryName:
Description: Name of the Git repository that contains custom Control Tower configuration. The suffix .git is prohibited.
Default: some-user/my-repo
Type: String

GitBranchName:
Description: Name of the branch in Git repository that contains custom Control Tower configuration.
Default: main
Type: String

ExistingRepository:
Description: Are you using an existing CodeCommit repository that already contains custom Control Tower configuration?
Default: 'No'
Expand Down Expand Up @@ -82,9 +95,11 @@ Metadata:
- PipelineApprovalEmail
- CodePipelineSource
- Label:
default: AWS CodeCommit Setup (Applicable if 'AWS CodeCommit' was selected as the CodePipeline Source)
default: Source Setup (Applicable if not selecting 'Amazon S3' as the CodePipeline Source)
Parameters:
- ExistingRepository
- GitRepositoryName
- GitBranchName
- CodeCommitRepositoryName
- CodeCommitBranchName
- Label:
Expand All @@ -103,6 +118,10 @@ Metadata:
default: AWS CodePipeline Source
ExistingRepository:
default: Existing CodeCommit Repository?
GitRepositoryName:
default: Git Repository Name
GitBranchName:
default: Git Branch Name
CodeCommitRepositoryName:
default: CodeCommit Repository Name
CodeCommitBranchName:
Expand Down Expand Up @@ -160,6 +179,7 @@ Conditions:
IsPipelineApprovalStageCondition: !Equals [!Ref PipelineApprovalStage, 'Yes']
IsBuildCustomControlTowerCondition: !Equals [!FindInMap [AutoBuild, CustomControlTower, Flag], 'Yes']
IsCodeCommitPipelineSource: !Equals [!Ref CodePipelineSource, 'AWS CodeCommit']
IsGit: !Or [!Equals [!Ref CodePipelineSource, 'GitHub'], !Equals [!Ref CodePipelineSource, 'GitHubEnterpriseServer'], !Equals [!Ref CodePipelineSource, 'Bitbucket']]
IsExistingRepository: !Equals [!Ref ExistingRepository, 'Yes']
IsNewCodeCommitRepository: !And [!Not [!Condition IsExistingRepository], !Condition IsCodeCommitPipelineSource]

Expand Down Expand Up @@ -388,6 +408,20 @@ Resources:
- "sns:Publish"
Resource: !Ref PipelineApprovalTopic
- !Ref AWS::NoValue
- !If
- IsGit
- Effect: "Allow"
Action:
- "codestar-connections:UseConnection"
Resource: !Ref GitConnection
- !Ref AWS::NoValue

GitConnection:
Type: AWS::CodeStarConnections::Connection
Condition: IsGit
Properties:
ConnectionName: Git-Customizations-Connection
ProviderType: !Ref CodePipelineSource

CustomControlTowerCodePipeline:
Type: AWS::CodePipeline::Pipeline
Expand All @@ -408,6 +442,12 @@ Resources:
Owner: AWS
Version: "1"
Provider: CodeCommit
- !If
- IsGit
- Category: Source
Owner: AWS
Version: "1"
Provider: CodeStarSourceConnection
- Category: Source
Owner: AWS
Version: "1"
Expand All @@ -419,6 +459,13 @@ Resources:
- IsCodeCommitPipelineSource
- RepositoryName: !Ref CodeCommitRepositoryName
BranchName: !Ref CodeCommitBranchName
- !If
- IsGit
- ConnectionArn: !Ref GitConnection
FullRepositoryId: !Ref GitRepositoryName
BranchName: !Ref GitBranchName
DetectChanges: true
OutputArtifactFormat: "CODEBUILD_CLONE_REF"
- S3Bucket: !Ref CustomControlTowerPipelineS3Bucket
S3ObjectKey: !FindInMap [BucketConfiguration, CustomControlTowerPipelineS3TriggerKey, Name]
RunOrder: 1
Expand Down Expand Up @@ -531,6 +578,13 @@ Resources:
Action:
- ssm:DescribeParameters
Resource: '*' # The APIs above only support '*' resource.
- !If
- IsGit
- Effect: "Allow"
Action:
- "codestar-connections:UseConnection"
Resource: !Ref GitConnection
- !Ref AWS::NoValue

CustomControlTowerCodeBuild:
Type: AWS::CodeBuild::Project
Expand Down