Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can we run Powershell script to use AWSPowerShell commands from bitbucket pipeline? Edited

Hi, I configured pipeline to run Powershell script that was working fine except AWS commands so tried to execute statements like given below but it is failing on Install-Package statement. What could be the reason (memory or permission issue) ?

param ([String]$environment,[String]$accessKey, [String] $secretKey, [String]$s3Region, [String]$bucketName, [String]$templateName, [String]$templatePath)

Install-Package -Name AWSPowerShell -Source https://www.powershellgallery.com/api/v2/ -ProviderName NuGet -ExcludeVersion -Destination /usr/local/share/powershell/Modules -Force

Set-AWSCredentials -AccessKey $accessKey -SecretKey $secretKey

Write-S3Object -BucketName $bucketName -File $templateName -Force -Key $templatePath -Region $s3Region

powershell-error.png

1 answer

Hi @Ranjit Sharma 

If I were you, I would preload PowerShell and any required modules onto the build agent to that they are always there for use

However, if that is not possible, and in the interests of faster build times, then you should use the modular AWS.Tools packages rather than the monolithic AWSPowerShell. AWS.Tools has a separate package for each AWS service, so you only install for the services you expect to use, e.g. AWS.Tools.S3. Also install the packages to user-space if you're doing it with each run of your plan

Install-Module AWS.Tools.Installer -Force -Scope CurrentUser
Install-AWSToolsModule AWS.Tools.S3 -Force -Scope CurrentUser -Cleanup
Set-AWSCredentials -AccessKey $accessKey -SecretKey $secretKey
Write-S3Object -BucketName $bucketName -File $templateName -Force -Key $templatePath -Region $s3Region

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,320 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you