Berry
Berry

Reputation: 2298

Run Powershell script on selected instance in CloudFormation template?

I am creating a CloudFormation where:

  1. An instance is selected
  2. The CloudFormation template has inputs that are to be used in the script
  3. Executes this script into the selected instance

How do I execute a Powershell script from CloudFormation?

Upvotes: 0

Views: 621

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269111

You can pass a PowerShell script via the User Data. It will be executed on the first startup of the instance.

Here is an example script:

<powershell>
$file = $env:SystemRoot + "\Temp\" + (Get-Date).ToString("MM-dd-yy-hh-mm")
New-Item $file -ItemType file
</powershell>

See: Running Commands on Your Windows Instance at Launch - Amazon Elastic Compute Cloud

Upvotes: 1

Related Questions