hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.17k forks source link

Remote-exec aws cli through winrm on windows fails #324

Closed hashibot closed 4 years ago

hashibot commented 7 years ago

This issue was originally opened by @stephensmalls as hashicorp/terraform#9562. It was migrated here as part of the provider split. The original body of the issue is below.


Hi there,

While sending an awscli command vi remote-exec to an AWS instance running windows 2012 r2 with aws cli installed give me an unrecognized aws cli error. but works flawlessly while logged into the instance interactively

Terraform Version

Terraform v0.7.5

Affected Resource(s)

provider "aws" { region = "us-east-1" }

resource "null_resource" "deploy_adfs_connection" { provisioner "remote-exec"{ inline = [ "\u0022aws s3 rm s3://devops.windows/saml/adfs.xml\u0022", "\u0022aws s3 cp C:\Windows\Temp\adfs.xml s3://devops.windows/saml/adfs.xml\u0022" ] connection { type = "winrm" host = "" user = "Administrator" password = "" timeout = "30m" } } }

Debug Output

Traceback (most recent call last): File "aws", line 27, in File "aws", line 23, in main File "awscli\clidriver.pyc", line 50, in main File "awscli\clidriver.pyc", line 178, in main File "awscli\argparser.pyc", line 71, in parse_known_args LookupError: unknown encoding: cp65001

Expected Behavior

on the instance I am able to run both commands without issue

Steps to Reproduce

I am unable to provide all of my deployment code, but I will say this. It's a vanilla windows 2012 r2 installation with the latest aws cli sdk installed. I am able to make a winrm connection and successfully run powershell scripts uploaded to the instance using a remote-exec resource.

Important Factoids

I have setup roles and profiles correctly as I am able to parse the meta-data of the instance and successfully run commands

Thanks!

jakemig commented 6 years ago

Ran into the same issue with Packer.

Worked around it by running chcp 850 in my script before calling the AWS CLI.

stephensmalls commented 6 years ago

That command soes not work on Windows 10. I'm running terraform from a windows machine.

On Thu, Mar 8, 2018 at 4:15 PM, Jake M notifications@github.com wrote:

Ran into the same issue https://github.com/hashicorp/packer/issues/3317#issuecomment-343978841 with Packer.

Worked around it by running chcp 850 in my script before calling the AWS CLI.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-aws/issues/324#issuecomment-371643195, or mute the thread https://github.com/notifications/unsubscribe-auth/APXTWxtEPXHIelBK0vs7y4t1y1Kk-_NIks5tca2FgaJpZM4N42q8 .

stephensmalls commented 6 years ago

I see, nevermind, I will try it.

On Tue, May 8, 2018 at 7:56 AM, Stephen Small stephensmall.it@gmail.com wrote:

That command soes not work on Windows 10. I'm running terraform from a windows machine.

On Thu, Mar 8, 2018 at 4:15 PM, Jake M notifications@github.com wrote:

Ran into the same issue https://github.com/hashicorp/packer/issues/3317#issuecomment-343978841 with Packer.

Worked around it by running chcp 850 in my script before calling the AWS CLI.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-aws/issues/324#issuecomment-371643195, or mute the thread https://github.com/notifications/unsubscribe-auth/APXTWxtEPXHIelBK0vs7y4t1y1Kk-_NIks5tca2FgaJpZM4N42q8 .

github-actions[bot] commented 4 years ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!