Skip to content

Commit

Permalink
Chore: Upgrade to dot net 8 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaway-c authored Oct 16, 2024
1 parent 7b2e166 commit 2d74a9f
Show file tree
Hide file tree
Showing 38 changed files with 897 additions and 436 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ jobs:
TAG: ${{ github.event.pull_request.head.sha }}
name: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.100
- uses: actions/setup-node@v3
dotnet-version: 8.0.x
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
- name: Run detect stage
id: vars
run: |
echo "STAGE=$(echo ${{github.head_ref}} | sed -r 's/[^a-z0-9-]/-/gi' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- run: npm run unit
- uses: aws-actions/configure-aws-credentials@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.CDK_DEFAULT_ACCOUNT }}:role/github-actions
role-duration-seconds: 900
Expand All @@ -42,7 +42,7 @@ jobs:
run: npx cdk deploy ${{ env.SERVICE }}-${{ env.STAGE }}-ecr --require-approval never
- name: Run login to aws ecr
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: "true"
- run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ jobs:
TAG: ${{ github.sha }}
name: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
- name: Run detect stage
id: vars
run: |
echo "STAGE=$(echo ${{github.head_ref}} | sed -r 's/[^a-z0-9-]/-/gi' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- uses: aws-actions/configure-aws-credentials@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.CDK_DEFAULT_ACCOUNT }}:role/github-actions
role-duration-seconds: 900
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
TAG: ${{ github.sha }}
name: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.100
- uses: actions/setup-node@v3
dotnet-version: 8.0.x
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
- uses: aws-actions/configure-aws-credentials@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.CDK_DEFAULT_ACCOUNT }}:role/github-actions
role-duration-seconds: 900
Expand All @@ -38,7 +38,7 @@ jobs:
run: npx cdk deploy ${{ env.SERVICE }}-${{ env.STAGE }}-ecr --require-approval never
- name: Run login to aws ecr
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: "true"
- run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
name: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.100
- uses: actions/setup-node@v3
dotnet-version: 8.0.x
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
- uses: aws-actions/configure-aws-credentials@v3
with:
Expand All @@ -38,7 +38,7 @@ jobs:
run: npx cdk deploy ${{ env.SERVICE }}-${{ env.STAGE }}-ecr --require-approval never
- name: Run login to aws ecr
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: "true"
- run: |
Expand Down
17 changes: 0 additions & 17 deletions .run/docker-compose.run.xml

This file was deleted.

21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ I have included the following Github Actions that run when creating PR’s into
## Prereqs

- Install VS Code for working in CDK in Typescript
- Install .Net 7 SDK https://dotnet.microsoft.com/en-us/download/dotnet/7.0
- Install Node.js 18 LTS https://nodejs.org/en/
- Install .Net 8 SDK https://dotnet.microsoft.com/en-us/download/dotnet/8.0
- Install Node.js 20 LTS https://nodejs.org/en/
- Install CDK cli tool globally https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html
- Install AWS cli tool https://aws.amazon.com/cli/ and setup default credentials using `aws configure`.

Expand All @@ -81,8 +81,7 @@ npm i
Create a `.env` file and add the following variables:

```
AWS_CONFIGURATION_DIRECTORY=~/.aws # The path to your AWS configuration directory. This is the standard location in Windows. MacOS, and Linux will be different.
AWS_PROFILE=todo-api-docker # This is the profile ECS local endpoints will look for when vending credentials to the docker container.
AWS_PROFILE=todo-api-docker # This is the profile ECS local endpoints will look for when vending credentials to the docker container. Note that integration/e2e tests will also use these creds when run locally.
AWS_REGION=<AWS_REGION>
CDK_DEFAULT_ACCOUNT=<AWS_ACCOUNT_ID>
CDK_DEFAULT_REGION=<AWS_REGION>
Expand All @@ -101,20 +100,6 @@ aws configure sso --profile todo-api

I have set this up to run with Docker-Compose in Rider. It probably works in Visual Studio as well, but I haven't tried it.

**Note:**

When running with Docker, the application uses [ECS local endpoints](https://github.com/awslabs/amazon-ecs-local-container-endpoints) to vend credentials to the container.
Unfortunately this is not compatible with AWS SSO 😿. You will need to copy the temporary access key/secret key/session token from your AWS SSO console.

Add the following to your `credentials` file located at `~/.aws/`:

```
[todo-api-docker]
aws_access_key_id=<AWS_SSO_ACCESS_KEY_ID>
aws_secret_access_key=<AWS_SSO_SECRET_ACCESS_KEY>
aws_session_token=<AWS_SSO_SESSION_TOKEN>
```

## Synth

Synth is useful during development to test out changes you're making to CDK. It doesn't actually deploy anything, it just
Expand Down
9 changes: 2 additions & 7 deletions cdk.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"app": "npx ts-node --prefer-ts-exts bin/stack.ts",
"watch": {
"include": [
"**"
],
"include": ["**"],
"exclude": [
"README.md",
"cdk*.json",
Expand All @@ -19,10 +17,7 @@
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
Expand Down
11 changes: 5 additions & 6 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,29 @@ services:
- /var/run:/var/run
# Mount the shared configuration directory, used by the AWS CLI and AWS SDKs
# On Windows, this directory can be found at "%UserProfile%\.aws"
- $AWS_CONFIGURATION_DIRECTORY:/home/.aws/
- ~/.aws:/home/.aws/
environment:
AWS_CONFIGURATION_DIRECTORY: $AWS_CONFIGURATION_DIRECTORY
AWS_PROFILE: $AWS_PROFILE
networks:
credentials_network:
# This special IP address is recognized by the AWS SDKs and AWS CLI
ipv4_address: "169.254.170.2"

todo-api:
depends_on:
- ecs-local-endpoints
networks:
credentials_network:
ipv4_address: "169.254.170.3"
# Note:
# Note:
# We have to override the entrypoint to allow the debugger to attach to the container
# The standard lambda entrypoint is not compatible with debugging
entrypoint: ["dotnet", "Todo.Api.dll"]
entrypoint: ["dotnet", "Todo.Api.dll"]
environment:
AWS_DEFAULT_REGION: $CDK_DEFAULT_REGION
AWS_REGION: $CDK_DEFAULT_REGION
ECS_CONTAINER_METADATA_URI: "http://169.254.170.2"
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: "/creds"
SERVICE: $SERVICE
STAGE: $STAGE
PORT: "80"
ASPNETCORE_URLS: http://localhost:8080/
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
context: .
dockerfile: src/Todo.Api/Dockerfile
ports:
- "5000:80"
- "5001:443"
- "5000:8080"
2 changes: 1 addition & 1 deletion lib/ecr-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class EcrStack extends cdk.Stack {
},
],
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteImages: true,
emptyOnDelete: true,
imageTagMutability: ecr.TagMutability.MUTABLE,
});
}
Expand Down
Loading

0 comments on commit 2d74a9f

Please sign in to comment.