The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Kyran McCann
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2022

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 12, 2022

@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.

DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events