1
votes

We are new to the Bitbucket CI/CD pipleline creations and AWS deployments.

We are trying to build and deploy/publish a .Net core (3.1) API to AWS Lambda as Serverless Application Model using Bitbucket pipeline. We have come across the below link to deploy to AWS.

https://bitbucket.org/atlassian/aws-sam-deploy/src/master/?_ga=2.18577786.215737733.1592837802-1805179932.1542868670

We were able to achieve project build and test but the AWS Lambda SAM deployment is not working correctly. Please find our below yaml file

image: mcr.microsoft.com/dotnet/core/sdk:3.1

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script: # Modify the commands below to build your repository.
          - export PROJECT_NAME=MyProject
          - export TEST_NAME=MyProject.Tests
          - dotnet restore
          - dotnet build $PROJECT_NAME
          - dotnet test $TEST_NAME
 
    - step:
        name: deploy AWS SAM  
        script:
          - pipe: atlassian/aws-sam-deploy:0.3.4
            variables:
             AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} # Optional if already defined in the context.
             AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} # Optional if already defined in the context.
             COMMAND: 'deploy' 

I think, we are missing few steps in the "deploy AWS SAM" but not sure how to provide the published libraries path or any other steps. We are not using any docker in our project.

Can someone help?

1

1 Answers

0
votes

I was facing the same issue. I found a solution that is not the best one, but works.

You can install the Amazon Lambda Tools in your pipeline image and call lambda deploy-serverless. Also, you need to install something to compress (zip) the package.

The "dotnet lambda deploy-serverless" does the same as the MS VS 2019 with AWS Toolkit.

image: mcr.microsoft.com/dotnet/core/sdk:3.1

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script: # Modify the commands below to build your repository.
          - apt-get update && apt-get install -y zip
          - dotnet tool install -g Amazon.Lambda.Tools
          - export PATH="$PATH:/root/.dotnet/tools"
          - dotnet lambda deploy-serverless