Last active
November 29, 2020 17:22
-
-
Save jbasinger/bfdb905e3bdb4bead20e68bc1f0185a7 to your computer and use it in GitHub Desktop.
Updated codebuild policy to allow access to cloudfront invalidations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
phases: | |
build: | |
commands: | |
- set -e | |
- docker-compose up -d site | |
- docker cp serverless-blazor:/app/ServerlessBlazor/build/wwwroot . | |
- docker-compose down | |
- aws s3 sync ./wwwroot s3://<YOUR S3 BUCKET NAME> | |
- aws cloudfront create-invalidation --distribution-id <YOUR CLOUDFRONT DISTRIBUTION ID> --paths "/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CodeBuildRole: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: !Join ["",['CodeBuild-', !Ref ProjectName]] | |
Path: /service-role/ | |
Policies: | |
- PolicyName: !Join ["",['CodeBuildBasePolicy-', !Ref ProjectName]] | |
PolicyDocument: | |
Statement: | |
- Effect: Allow | |
Resource: | |
- !Join ["",["arn:aws:logs:", !Ref "AWS::Region", ":", !Ref "AWS::AccountId", ":log-group:/aws/codebuild/", !Ref ProjectName]] | |
- !Join ["",["arn:aws:logs:", !Ref "AWS::Region", ":", !Ref "AWS::AccountId", ":log-group:/aws/codebuild/", !Ref ProjectName, ":*"]] | |
Action: | |
- "logs:CreateLogGroup" | |
- "logs:CreateLogStream" | |
- "logs:PutLogEvents" | |
- Effect: Allow | |
Resource: | |
- !Join ["",["arn:aws:s3:::", !Ref BucketName]] | |
- !Join ["",["arn:aws:s3:::", !Ref BucketName, "/*"]] | |
Action: | |
- "s3:PutObject" | |
- "s3:GetBucketAcl" | |
- "s3:GetBucketLocation" | |
- "s3:ListBucket" | |
- Effect: Allow | |
Resource: "*" | |
Action: ["cloudfront:CreateInvalidation"] | |
AssumeRolePolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- codebuild.amazonaws.com | |
Action: | |
- 'sts:AssumeRole' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
site: | |
container_name: serverless-blazor | |
build: . | |
command: dotnet run /app/ServerlessBlazor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build | |
WORKDIR /app | |
COPY . . | |
RUN dotnet restore | |
WORKDIR /app/ServerlessBlazor/ | |
RUN dotnet publish -c Release -o build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment