Sample App Deployment - Dotnet S3 #55
This file contains hidden or 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
| ## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
| ## SPDX-License-Identifier: Apache-2.0 | |
| name: Sample App Deployment - Dotnet S3 | |
| on: | |
| workflow_dispatch: # be able to run the workflow on demand | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| upload-sample-app-zip: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| aws-region: [ 'af-south-1','ap-east-1','ap-northeast-1','ap-northeast-2','ap-northeast-3','ap-south-1','ap-south-2','ap-southeast-1', | |
| 'ap-southeast-2','ap-southeast-3','ap-southeast-4','ca-central-1','eu-central-1','eu-central-2','eu-north-1', | |
| 'eu-south-1','eu-south-2','eu-west-1','eu-west-2','eu-west-3','il-central-1','me-central-1','me-south-1', 'sa-east-1', | |
| 'us-east-1','us-east-2', 'us-west-1', 'us-west-2' ] | |
| dotnet-version: [ '6.0', '8.0' ] | |
| runs-on: ubuntu-latest | |
| env: | |
| DEFAULT_VERSION: '8.0' | |
| DOTNET_VERSION: ${{ matrix.dotnet-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.E2E_IAD_TEST_ACCOUNT_ARN }} | |
| aws-region: us-east-1 | |
| - name: Retrieve account | |
| uses: aws-actions/aws-secretsmanager-get-secrets@v1 | |
| with: | |
| secret-ids: | |
| ACCOUNT_ID, region-account/${{ matrix.aws-region }} | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }} | |
| aws-region: ${{ matrix.aws-region }} | |
| - name: Update .NET version if not default | |
| working-directory: sample-apps/dotnet | |
| run: | | |
| if [ "${DOTNET_VERSION}" != "${DEFAULT_VERSION}" ]; then | |
| echo "Updating .NET version from ${DEFAULT_VERSION} to ${DOTNET_VERSION}" | |
| # Function to update version in files | |
| update_version() { | |
| local file=$1 | |
| if [ ! -f "$file" ]; then | |
| echo "Error: File $file not found" | |
| exit 1 | |
| fi | |
| # Update TargetFramework in csproj files | |
| if [[ $file == *.csproj ]]; then | |
| sed -i "s/<TargetFramework>netcoreapp${DEFAULT_VERSION}<\/TargetFramework>/<TargetFramework>netcoreapp${DOTNET_VERSION}<\/TargetFramework>/g" "$file" | |
| fi | |
| if [ $? -ne 0 ]; then | |
| echo "Error: Failed to update version in $file" | |
| exit 1 | |
| fi | |
| echo "Successfully updated $file" | |
| } | |
| # Update all relevant files | |
| update_version "asp_frontend_service/asp_frontend_service.csproj" | |
| update_version "asp_remote_service/asp_remote_service.csproj" | |
| # Verify changes | |
| echo "Verifying changes..." | |
| echo "=== Frontend csproj ===" | |
| grep -n "TargetFramework" asp_frontend_service/asp_frontend_service.csproj | |
| echo "=== Remote csproj ===" | |
| grep -n "TargetFramework" asp_remote_service/asp_remote_service.csproj | |
| else | |
| echo "Using default version ${DEFAULT_VERSION}, no changes needed" | |
| fi | |
| - name: Build Sample App Zip | |
| working-directory: sample-apps/dotnet | |
| run: zip -r dotnet-sample-app-${DOTNET_VERSION}.zip . | |
| - name: Upload to S3 | |
| working-directory: sample-apps/dotnet | |
| run: aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ matrix.aws-region }} --body ./dotnet-sample-app-${DOTNET_VERSION}.zip --key dotnet-sample-app-${DOTNET_VERSION}.zip | |
| - name: Upload Windows Script to S3 | |
| working-directory: sample-apps/dotnet | |
| run: | | |
| aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ matrix.aws-region }} --body ./dotnet-ec2-win-main-setup.ps1 --key dotnet-ec2-win-main-setup.ps1 | |
| aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ matrix.aws-region }} --body ./dotnet-ec2-win-remote-setup.ps1 --key dotnet-ec2-win-remote-setup.ps1 | |
| aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ matrix.aws-region }} --body ./amazon-cloudwatch-agent.json --key amazon-cloudwatch-agent.json | |
| build-and-upload-lambda-sample-app: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| aws-region: [ 'af-south-1','ap-east-1','ap-northeast-1','ap-northeast-2','ap-northeast-3','ap-south-1','ap-south-2','ap-southeast-1', | |
| 'ap-southeast-2','ap-southeast-3','ap-southeast-4','ca-central-1','eu-central-1','eu-central-2','eu-north-1', | |
| 'eu-south-1','eu-south-2','eu-west-1','eu-west-2','eu-west-3','il-central-1','me-central-1','me-south-1', 'sa-east-1', | |
| 'us-east-1','us-east-2', 'us-west-1', 'us-west-2' ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout sample app repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: 'aws-observability/aws-otel-dotnet-instrumentation' | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.E2E_IAD_TEST_ACCOUNT_ARN }} | |
| aws-region: us-east-1 | |
| - name: Retrieve account | |
| uses: aws-actions/aws-secretsmanager-get-secrets@v1 | |
| with: | |
| secret-ids: | |
| ACCOUNT_ID, region-account/${{ matrix.aws-region }} | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }} | |
| aws-region: ${{ matrix.aws-region }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v2 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Setup .NET Lambda Tools | |
| shell: bash | |
| run: dotnet tool install -g Amazon.Lambda.Tools | |
| working-directory: sample-applications/lambda-test-apps/SimpleLambdaFunction | |
| - name: Build Lambda Sample App | |
| shell: bash | |
| run: dotnet lambda package -pl ./src/SimpleLambdaFunction | |
| working-directory: sample-applications/lambda-test-apps/SimpleLambdaFunction | |
| - name: Upload Lambda Sample App to S3 | |
| working-directory: sample-applications/lambda-test-apps/SimpleLambdaFunction | |
| run: aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ matrix.aws-region }} --body ./src/SimpleLambdaFunction/bin/Release/net8.0/SimpleLambdaFunction.zip --key dotnet-function.zip |