Skip to content

aws/aws-toolkit-azure-devops

Repository files navigation

Overview

Coverage: codecov

The AWS Toolkit for Azure DevOps adds tasks to easily enable build and release pipelines in Azure DevOps (formerly VSTS) and Azure DevOps Server (previously known as Team Foundation Server (TFS)) to work with AWS services including Amazon S3, AWS Elastic Beanstalk, AWS CodeDeploy, AWS Lambda, AWS CloudFormation, Amazon Simple Queue Service and Amazon Simple Notification Service, and run commands using the AWS Tools for Windows PowerShell module and the AWS CLI.

The AWS Toolkit for Azure DevOps is available from the Visual Studio Marketplace.

This is an open source project because we want you to be involved. We love issues, feature requests, code reviews, pull requests or any positive contribution. Please see the the CONTRIBUTING guide for how to help, including how to build your own extension.

Highlighted Features

  • AWSCLI - Interact with the AWSCLI (Windows hosts only)
  • AWS Powershell Module - Interact with AWS through powershell (Windows hosts only)
  • Beanstalk - Deploy ElasticBeanstalk applications
  • CodeDeploy - Deploy with CodeDeploy
  • CloudFormation - Create/Delete/Update CloudFormation stacks
  • ECR - Push an image to an ECR repository
  • Lambda - Deploy from S3, .net core applications, or any other language that builds on Azure DevOps
  • S3 - Upload/Download to/from S3 buckets
  • Secrets Manager - Create and retrieve secrets
  • SQS - Send SQS messages
  • SNS - Send SNS messages
  • Systems manager - Get/set parameters and run commands

User Guide

The User Guide contains additional instructions for getting up and running with the extension.

Credentials Handling for AWS Services

To enable tasks to call AWS services when run as part of your build or release pipelines, AWS credentials need to have been configured for the tasks or be available in the host process for the build agent. Note that the credentials are used specifically by the tasks when run in a build agent process, they are not related to end-user logins to your Azure DevOps instance.

The AWS tasks support the following mechanisms for obtaining AWS credentials:

One or more service endpoints, of type AWS, can be created and populated with either:

  • Static credentials in the form of AWS access and secret keys, and optionally data for Assumed Role credentials.

  • If only the Assumed Role is defined but neither access key ID nor secret key, the role will be assumed regardless. This is useful when using instance profiles, and profile which only allows to assume a role.

  • If Use OIDC is checked and you have defined an Assumed Role without an access key ID or secret key, an OIDC token will be requested from Azure Devops and used to federate into AWS.

    • Using OIDC requires the creation of an OIDC Provider. Please refer to the documentation here: Creating and managing an OIDC provider
    • This will also require a trust policy on the Assume Role similar to this :
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Principal": {
                    "Federated": "arn:aws:iam::123456789012:oidc-provider/vstoken.dev.azure.com/{org-id}"
                },
                "Action": "sts:AssumeRoleWithWebIdentity",
                "Condition": {
                    "StringEquals": {
                        "vstoken.dev.azure.com/{org-id}:sub": "sc://{orgName}/{ProjectName}/{ServiceConnectionName}",
                        "vstoken.dev.azure.com/{org-id}:aud": "api://AzureADTokenExchange"
                    }
                }
            }
        ]
    }
    • A sample CloudFormation template example_cfn.yml is available to assist with the setup and configuration.
  • Variables defined on the task or build.

    • If tasks are not configured with the name of a service endpoint they will attempt to obtain credentials, and optionally region, from variables defined in the build environment. The variables are named AWS.AccessKeyID, AWS.SecretAccessKey and optionally AWS.SessionToken. To supply the ID of the region to make the call in, e.g. us-west-2, you can also use the variable AWS.Region. Optionally a role to assume can be specified by using the variable AWS.AssumeRoleArn. When assuming roles AWS.RoleSessionName (optional) and AWS.ExternalId (optional) can be provided in order to specify an identifier for the assumed role session and an external id to show in customers' accounts when assuming roles.
  • Environment variables in the build agent's environment.

    • If tasks are not configured with the name of a service endpoint, and credentials or region are not available from task variables, the tasks will attempt to obtain credentials, and optionally region, from standard environment variables in the build process environment. These variables are AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and optionally AWS_SESSION_TOKEN. To supply the ID of the region to make the call in, e.g. us-west-2, you can also use the environment variable AWS_REGION.
  • EC2 instance metadata, for build hosts running on EC2 instances.

    • Both credential and region information can be automatically obtained from the instance metadata in this scenario.

Configuring an AWS Service Endpoint

To use AWS service endpoints add the AWS subscription(s) to use by opening the Account Administration screen (gear icon on the top-right of the screen) and then click on the Services Tab. Note that each Azure DevOps project is associated with its own set of credentials. Service endpoints are not shared across projects. You can associate a single service endpoint to be used with all AWS tasks in a build or multiple endpoints if you require.

Select the AWS endpoint type and provide the following parameters based on the type of authentification above.

OIDC Federation

  • A name used to refer to the credentials when configuring the AWS tasks
  • The arn of the role to assume
  • Check the useOIDC options

Static credentials

Please refer to About Access Keys:

  • A name used to refer to the credentials when configuring the AWS tasks
  • AWS Access Key ID
  • AWS Secret Access Key

Assume Role

Tasks can also use assumed role credentials by adding the Amazon Resource name (ARN) of the role to be assumed and an optional identifier when configuring the endpoint. The access and secret keys specified will then be used to generate temporary credentials for the tasks when they are executed by the build agents. Temporary credentials are valid for up to 15 minutes by default. To enable a longer validity period you can set the 'aws.rolecredential.maxduration' variable on your build or release definition, specifying a validity period in seconds between 15 minutes (900 seconds) and 12 hours (43200 seconds).

Note

We strongly suggest to use the OIDC Federation to avoid having to maintain static credentials. You can configure an IAM role with permissions granting access to only the services and resources required to support the tasks you intend to use in your build and release definitions.

Supported environments

  • Azure DevOps
  • Team Foundation Server 2017 Update 1 (or higher) (now called Azure DevOps Server)

License

The project is licensed under the MIT license

Contributors

We thank the following contributor(s) for this extension: Visual Studio ALM Rangers.