-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Amazon DynamoDB stream infrastructure
- Loading branch information
Showing
4 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
infrastructure/exposing-amazon-dynamodb-stream-apprunner.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
|
||
Parameters: | ||
AppName: | ||
Type: String | ||
Default: 'app-exposing-dynamodb-stream' | ||
AppVersion: | ||
Type: String | ||
Default: '1.0.0' | ||
|
||
Resources: | ||
ProjectContainerRegistryAccessRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
RoleName: !Sub '${AppName}-access-role' | ||
AssumeRolePolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- build.apprunner.amazonaws.com | ||
Action: sts:AssumeRole | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess | ||
ProjectAppRunnerServiceInstanceRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
RoleName: !Sub '${AppName}-instance-role' | ||
AssumeRolePolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- tasks.apprunner.amazonaws.com | ||
Action: sts:AssumeRole | ||
ManagedPolicyArns: | ||
# This is overly permissive, just for a demo | ||
- arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess | ||
ProjectAppRunnerService: | ||
Type: AWS::AppRunner::Service | ||
Properties: | ||
ServiceName: !Sub '${AppName}-app' | ||
SourceConfiguration: | ||
AuthenticationConfiguration: | ||
AccessRoleArn: !GetAtt ProjectContainerRegistryAccessRole.Arn | ||
AutoDeploymentsEnabled: true | ||
ImageRepository: | ||
ImageIdentifier: !Sub '${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${AppName}-repository:${AppVersion}' | ||
ImageRepositoryType: 'ECR' | ||
ImageConfiguration: | ||
Port: 8080 | ||
RuntimeEnvironmentVariables: [ | ||
{ | ||
'Name': 'ChangefeedService', | ||
'Value': 'AmazonDynamoDB' | ||
}, | ||
{ | ||
'Name': 'AmazonDynamoDB__RegionSystemName', | ||
'Value': !Sub '${AWS::Region}' | ||
} | ||
] | ||
InstanceConfiguration: | ||
Cpu: '0.25 vCPU' | ||
Memory: '0.5 GB' | ||
InstanceRoleArn: !GetAtt ProjectAppRunnerServiceInstanceRole.Arn |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
|
||
Parameters: | ||
AppName: | ||
Type: String | ||
Default: 'app-exposing-dynamodb-stream' | ||
|
||
Resources: | ||
ProjectContainerRegistry: | ||
Type: AWS::ECR::Repository | ||
Properties: | ||
RepositoryName: !Sub '${AppName}-repository' | ||
EmptyOnDelete: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ARG SDK_VERSION=8.0-jammy | ||
ARG ASPNET_VERSION=8.0-jammy-chiseled | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:$SDK_VERSION AS build-env | ||
WORKDIR /src | ||
|
||
COPY . . | ||
RUN dotnet restore /src/Demo.AspNetCore.Changefeed \ | ||
--runtime linux-x64 | ||
|
||
RUN dotnet publish /src/Demo.AspNetCore.Changefeed \ | ||
--no-restore \ | ||
--runtime linux-x64 \ | ||
--configuration Release \ | ||
--output /app/publish | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:$ASPNET_VERSION | ||
USER $APP_UID | ||
WORKDIR /app | ||
COPY --from=build-env /app/publish . | ||
EXPOSE 8080 | ||
ENTRYPOINT ["./Demo.AspNetCore.Changefeed"] |