diff --git a/cloudformation/Makefile b/cloudformation/Makefile index 3e7138b..5b4bd07 100644 --- a/cloudformation/Makefile +++ b/cloudformation/Makefile @@ -8,9 +8,7 @@ ## STACK_NAME=graphql -GITHUB_REPO := graphql-api-js -GITHUB_USER := Photowall -$(eval GITHUB_TOKEN=$(shell aws ssm get-parameter --with-decryption --name /github/CODE_PIPELINE_TOKEN --output text --query Parameter.Value)) +GITHUB_REPO := Photowall/graphql-api-js AWS_REGION=$(shell aws configure get region) AWS_ACCOUNT_ID=$(shell aws sts get-caller-identity --query Account --output text) @@ -81,8 +79,6 @@ check-create-variables-set: $(call checkdef,STACK_NAME) $(call checkdef,STACK_ENVIRONMENT_NAME) $(call checkdef,ENVIRONMENT_NAME) - $(call checkdef,GITHUB_TOKEN) - $(call checkdef,GITHUB_USER) $(call checkdef,GITHUB_REPO) check-update-variables-set: @@ -111,9 +107,7 @@ create-stack: check-create-variables-set check-create-initial-ecr-image ParameterKey="Certificate",ParameterValue="$(CERTIFICATE_ARN)" \ ParameterKey="DatabaseSecurityGroup",ParameterValue="$(DB_SECURITY_GROUP_ID)" \ ParameterKey="GitHubRepo",ParameterValue="$(GITHUB_REPO)" \ - ParameterKey="GitHubUser",ParameterValue="$(GITHUB_USER)" \ ParameterKey="GitHubBranch",ParameterValue="$(GITHUB_BRANCH)" \ - ParameterKey="GitHubToken",ParameterValue="$(GITHUB_TOKEN)" \ ParameterKey="CpuSize",ParameterValue="$(CPU_SIZE)" \ ParameterKey="MemorySize",ParameterValue="$(MEMORY_SIZE)" \ ParameterKey="ImagesBucket",ParameterValue="$(IMAGES_BUCKET)" \ @@ -130,10 +124,8 @@ update-stack: set-repository-lifecycle-policy ParameterKey="Subdomain",UsePreviousValue=true \ ParameterKey="Certificate",UsePreviousValue=true \ ParameterKey="DatabaseSecurityGroup",,UsePreviousValue=true \ - ParameterKey="GitHubRepo",UsePreviousValue=true \ - ParameterKey="GitHubUser",UsePreviousValue=true \ + ParameterKey="GitHubRepo",ParameterValue="$(GITHUB_REPO)" \ ParameterKey="GitHubBranch",UsePreviousValue=true \ - ParameterKey="GitHubToken",UsePreviousValue=true \ ParameterKey="CpuSize",ParameterValue="$(CPU_SIZE)" \ ParameterKey="MemorySize",ParameterValue="$(MEMORY_SIZE)" \ ParameterKey="ImagesBucket",ParameterValue="$(IMAGES_BUCKET)" \ diff --git a/cloudformation/ecs-service.yaml b/cloudformation/ecs-service.yaml index 8ecebee..d81144d 100644 --- a/cloudformation/ecs-service.yaml +++ b/cloudformation/ecs-service.yaml @@ -81,11 +81,12 @@ Parameters: Type: String GitHubBranch: Type: String - GitHubToken: - Type: String - NoEcho: true - GitHubUser: + + # ARN for manually created github connection + # It cannot fully be setup in cloudformation (due to auth step on github end) and makes sense to reuse between stacks + GithubConnectionArn: Type: String + Default: arn:aws:codestar-connections:eu-west-1:954747537408:connection/a5003038-5011-47d7-98ed-2ff15b290ab3 # Buckets ImagesBucket: @@ -456,6 +457,11 @@ Resources: - codebuild:StartBuild - codebuild:BatchGetBuilds - iam:PassRole + - Resource: + - !Ref GithubConnectionArn + Effect: Allow + Action: + - codestar-connections:UseConnection ArtifactBucket: Type: AWS::S3::Bucket @@ -531,14 +537,13 @@ Resources: - Name: App ActionTypeId: Category: Source - Owner: ThirdParty + Owner: AWS Version: 1 - Provider: GitHub + Provider: CodeStarSourceConnection Configuration: - Owner: !Ref GitHubUser - Repo: !Ref GitHubRepo - Branch: !Ref GitHubBranch - OAuthToken: !Ref GitHubToken + ConnectionArn: !Ref GithubConnectionArn + FullRepositoryId: !Ref GitHubRepo + BranchName: !Ref GitHubBranch OutputArtifacts: - Name: App RunOrder: 1