Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kierantrainor opened this issue Oct 3, 2024 · 0 comments
Open

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

kierantrainor opened this issue Oct 3, 2024 · 0 comments

Comments

@kierantrainor
Copy link

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"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant