Skip to content

AWSCLI - Interact with the AWSCLI - linux build host #569

@kierantrainor

Description

@kierantrainor

In the documentation it mentions the following :

AWSCLI - Interact with the AWSCLI (Windows hosts only)

Im using linux build host and it works fine, i just want to know why this line has been included in the documentation:

Reference:
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.aws-vsts-tools

https://aws.amazon.com/blogs/devops/use-the-aws-toolkit-for-azure-devops-to-automate-your-deployments-to-aws/

I export the Credentials to use in later bash tasks

My task :

  • task: AWSShellScript@1
    displayName: "Assume AWS Role"
    inputs:
    awsCredentials: "ado-connection"
    regionName: "eu-west-1"
    failOnStderr: true
    workingDirectory: "$(System.DefaultWorkingDirectory)"
    scriptType: 'inline'
    inlineScript: |
    # Set AWS Credentials and Assume Role
    echo "Current Identity"
    aws sts get-caller-identity

    role_arn="${{ parameters.assume_role }}"
    echo "Assuming role $role_arn"
    
    temp_role=$(aws sts assume-role --role-arn $role_arn --role-session-name Azure-Dev-Ops)
    
    AWS_ACCESS_KEY_ID=$(echo $temp_role | jq -r .Credentials.AccessKeyId)
    AWS_SECRET_ACCESS_KEY=$(echo $temp_role | jq -r .Credentials.SecretAccessKey)
    AWS_SESSION_TOKEN=$(echo $temp_role | jq -r .Credentials.SessionToken)
    
    echo "AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID"
    
    # Set environment variables for future tasks
    echo "##vso[task.setvariable variable=AWS_ACCESS_KEY_ID;isSecret=true]$AWS_ACCESS_KEY_ID"
    echo "##vso[task.setvariable variable=AWS_SECRET_ACCESS_KEY;isSecret=true]$AWS_SECRET_ACCESS_KEY"
    echo "##vso[task.setvariable variable=AWS_SESSION_TOKEN;isSecret=true]$AWS_SESSION_TOKEN"
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions