Skip to content

Instantly share code, notes, and snippets.

@leandrosiow
Last active February 11, 2020 05:01
Show Gist options
  • Select an option

  • Save leandrosiow/99104a058d622de6af91417dafc91609 to your computer and use it in GitHub Desktop.

Select an option

Save leandrosiow/99104a058d622de6af91417dafc91609 to your computer and use it in GitHub Desktop.
Here is a workaround for ECS Windows GitHub Issue: [Windows Credential Proxy Unavailable after EC2 Stop/Start #2135] https://github.com/aws/amazon-ecs-agent/issues/2135
<powershell>
C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule
netsh interface portproxy delete v4tov4 80 169.254.170.2 | out-null
[Environment]::SetEnvironmentVariable('ECS_DISABLE_METRICS', 'false', 'Machine')
[Environment]::SetEnvironmentVariable('ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE', $TRUE, 'Machine')
Initialize-ECSAgent -Cluster Windows -EnableTaskIAMRole -LoggingDrivers '["json-file","awslogs"]'
</powershell>
@leandrosiow
Copy link
Author

leandrosiow commented Feb 11, 2020

Windows Credential Proxy Unavailable after EC2 Stop/Start #2135
aws/amazon-ecs-agent#2135 (comment)

The Workaround
Run the following command after a Start/Stop

netsh interface portproxy delete v4tov4 80 169.254.170.2
Initialize-ECSAgent -Cluster Windows -EnableTaskIAMRole -LoggingDrivers '["json-file","awslogs"]'

Please refer to the above userdata.ps for the full UserData script.

The Error
[INFO] TaskHandler: batching container event: arn:aws:ecs:eu-west-1:ACCOUNT_ID:task/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX windows -> STOPPED, Reason CannotStartContainerError: Error response from daemon: failed to initialize logging driver: failed to create Cloudwatch log stream: CredentialsEndpointError: failed to load credentials
caused by: RequestError: send request failed
caused by: Get http://169.254.170.2/v2/credentials/12f7f583-f11f-45f9-9a07-e7b237b72a72: dial tcp 169.254.170.2:80: connectex: A socket operation was attempted to an unreachable network., Known Sent: NONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment