JasonWH
JasonWH

Reputation: 179

Changing EC2 Instance Type via Powershell

I'm running into what I'm sure is a simple issue I'm overlooking. I'm trying to change an AWS EC2 InstanceType using the CLI via a Powershell Script. Everything is running fine up until I go to actually modify the InstanceType.

I've tried multiple different variations and combinations of escape characters to get this to work, but I can't so far.

Invoke-Expression 'aws ec2 modify-instance-attribute --instance-id $thisID --instance-type \"{`\"Value`\":`\"m4.large`\"}"'

What I'm trying to achieve is the equivalent to this:

aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --instance-type "{\"Value\": \"m1.small\"}"

Upvotes: 1

Views: 1095

Answers (1)

Peter Kay
Peter Kay

Reputation: 996

You can use the AWS Tools for Powershell and use the following command:

Edit-EC2InstanceAttribute -InstanceId $thisID --InstanceType m4.large

Documentation Reference: https://docs.aws.amazon.com/powershell/latest/reference/Index.html

Upvotes: 3

Related Questions