Codefresh Steps: Reusable Code for Common Operations
This page provides code you can use to perform common operations in the Codefresh CI/CD platform.
12.2K

aws-sts-assume-role-with-web-identity aws-sts-assume-role-with-web-identity

Obtain AWS STS credentials using OIDC ID token and export them as environment variables

arguments

  • ROLE_ARN - the ARN of the role to assume
  • ROLE_SESSION_NAME - the name of the session
  • WEB_IDENTITY_TOKEN - the OIDC ID token. If not provided, the step will try to read it from the environment variable ID_TOKEN (which is set by the obtain-oidc-id-token step)

returns

  • AWS_ACCESS_KEY_ID - the AWS access key id
  • AWS_SECRET_ACCESS_KEY - the AWS secret access key
  • AWS_SESSION_TOKEN - the AWS session token
    version: '1.0'
steps:
  obtain_id_token:
    title: Obtain ID Token
    type: obtain-oidc-id-token
  assume_role:
    title: Assume Role
    type: aws-sts-assume-role-with-web-identity
    arguments:
      ROLE_ARN: 'arn:aws:iam::123456789012:role/role-name'
      ROLE_SESSION_NAME: session-name
  s3_list_objects:
    title: List S3 Objects
    image: amazon/aws-cli
    commands:
      - 'aws s3 ls "s3://bucket-name/"'

  
    version: '1.0'
steps:
  assume_role:
    title: Assume Role
    type: aws-sts-assume-role-with-web-identity
    arguments:
      ROLE_ARN: 'arn:aws:iam::123456789012:role/role-name'
      ROLE_SESSION_NAME: session-name
      WEB_IDENTITY_TOKEN: '${{ID_TOKEN}}'
  s3_list_objects:
    title: List S3 Objects
    image: amazon/aws-cli
    commands:
      - 'aws s3 ls "s3://bucket-name/"'

  
github.com
Daniel Soifer
Feb 13, 2024