Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,331,490
Community Members
 
Community Events
169
Community Groups

How do I Update Lambda Environment Variables using aws-lambda-deploy?

Edited

Edit to add: i updated the pipe version to 1.6.0 and updated path to config file to './stagingconfig.json' and it worked fine. 

I'm updating and aliasing. I can't seem to figure out the syntax/order of operations to properly update the environment variables when doing the update. 

The variables that I want to use are stored with the bitbucket-pipelines.yml file. 

bitbucket-pipelines.yml: 

pipelines:
  default:
    - step:
        # Build and package the Lambda function.
        name: Build and package
        script:
          - apt-get update && apt-get install -y zip
          - zip code.zip lambda-name/*

          # Upload the Lambda - make the version number
          #available to subsequent steps via artifacts.
          - pipe: atlassian/aws-lambda-deploy:0.2.1
            variables:
              AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
              AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
              AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
              FUNCTION_NAME: 'lambda-name'
              COMMAND: 'update'
              ZIP_FILE: 'code.zip'
              WAIT: 'true'

        # The pipe exports the newly published
        # Lambda version to a file.
        artifacts:
          - pipe.meta.env

    # You can optionally use AWS Lambda aliases
    # to map the newly published Lambda
    # function version to conceptual environments.

    - step:
        name: Deploy to Staging
        deployment: Staging
        script:
        # Read the 'function_version' from
        # the update pipe into environment variables.
        - source pipe.meta.env
        # Point the 'staging' alias to the function.
        - pipe: atlassian/aws-lambda-deploy:0.2.1
          variables:
            AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
            AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
            AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
            SecretName: $SecretName
            FUNCTION_NAME: 'eip-put-rrt'
            COMMAND: 'alias'
            FUNCTION_CONFIGURATION: '~/stagingconfig.json'
            ALIAS: 'dev'
            VERSION: '${function_version}'

 

stagingconfig.json (in root folder): 

{
    "Environment": {
        "Variables": {
            "Region": "$AWS_DEFAULT_REGION",
            "SecretName": "$SecretName",
            "BucketName": "$BUCKET_NAME"
        }
    }
}



1 answer

0 votes

@Kyran McCann . Thank you for sharing your feedback. It' is always good idea to use latest versions of the pipes, because we provide new features and also maintenance.

Regards, Igor.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,990 views 3 10
Read article

Atlassian Community Events