Skip to content

How do I troubleshoot PLA failures in AWS Transform MGN or Elastic Disaster Recovery?

6 minute read
0

I want to troubleshoot post-launch action (PLA) failures in AWS Transform MGN or AWS Elastic Disaster Recovery.

Short description

AWS Transform MGN and Elastic Disaster Recovery use AWS Systems Manager to run automation documents on Amazon Elastic Compute Cloud (Amazon EC2) instances after launch. To troubleshoot PLAs that fail, first make sure that your configuration meets the Systems Manager requirements. If you still encounter issues, then troubleshoot based on the error message that you receive.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Make sure that your configuration meets the Systems Manager requirements

Check your IAM permissions

The Amazon EC2 instance's AWS Identity and Access Management (IAM) roles must have the required permissions to launch PLAs based on your configuration. By default, the service-linked roles have the required permissions. If you updated the role or created a custom role, then make sure that the role has the following permissions:

{
  "Effect": "Allow",
  "Action": [
    "ssm:SendCommand",
    "ssm:GetCommandInvocation",
    "ssm:DescribeInstanceInformation",
    "ssm:StartAutomationExecution",
    "ssm:GetAutomationExecution"
  ],
  "Resource": "*"
}

For AWS Transform MGN, check the post-launch template to confirm that the EC2 instance profile role has the AmazonSSMManagedInstanceCore policy. For Elastic Disaster Recovery, see Install the required IAM roles if needed.

Make sure that your system is ready to run PLAs

Take the following actions:

  • Make sure that AWS Systems Manager Agent (SSM Agent) is installed and running on the target instance.
    Note: AWS Transform MGN and Elastic Disaster Recovery automatically install the SSM Agent. However, installation might fail if there are network connectivity, IAM permissions, or operating system (OS) issues.
  • Confirm that the instance can reach the following required endpoints through internet access, a NAT gateway, or virtual private cloud (VPC) endpoints:
    ssm.us-east-1.amazonaws.com
    ssmmessages.us-east-1.amazonaws.com
    ec2messages.us-east-1.amazonaws.com
    s3.us-east-1.amazonaws.com
    Note: Replace us-east-1 with your AWS Region. If you use VPC endpoints, then the endpoint's security group must allow inbound traffic on port 443 from the instance.
  • Make sure that SSM Agent is online.
    Note: If SSM Agent is offline, then the PLA status becomes stuck on the In Progress state or has no status. Because of how often the services check the status, you might have a 5-minute delay between when SSM Agent comes online and when the PLA starts.
  • To confirm that the AWS Systems Manager document (SSM document) exists in the target Region, run the following describe-document AWS CLI command:
    aws ssm describe-document --name your-document-name --region us-east-1
    Note: Replace your-document-name with the document name in the post-launch template and us-east-1 with your Region.
  • Make sure that the instance passes its status checks.

Troubleshoot PLAs that fail with "AccessDeniedException" error messages

If you're missing required permissions, then you receive the "AccessDeniedException" error message.

Check the AWS CloudTrail Event history for SendCommand or StartAutomationExecution events. Use the event error codes to identify the missing permission.

Make sure that the service-linked role for AWS Transform MGN or Elastic Disaster Recovery exists and has the required managed policy. Make sure that the managed policy hasn't been modified.

If you use custom SSM documents with an AutomationAssumeRole, then confirm that the role exists and that you correctly configured permissions. For more information, see Accelerating Blue/Green Deployments with AWS MGN Post-Launch Actions.

Check your service control policies (SCPs) for rules that block Systems Manager actions.

To configure PLAs across AWS accounts, make sure that you configured the required roles. For Elastic Disaster Recovery, see Adding a trusted account in Elastic Disaster Recovery. For AWS Transform MGN, the PLAs run in the target account where you launched the instance. If your custom SSM documents require access to resources in another account, then set up cross-account access.

Troubleshoot PLAs that fail with "InvalidInstanceId" error messages

If the instance ID is incorrect or the instance is misconfigured, then you receive an "InvalidInstanceId" error message.

To resolve this issue, take the following actions:

  • Confirm that the target instance still exists in the Amazon EC2 console.
  • Confirm that the instance is registered in Fleet Manager, a capability of AWS Systems Manager.
  • Make sure that the instance profile is still attached to the instance.
  • Check for errors in the SSM Agent logs at /var/log/amazon/ssm/amazon-ssm-agent.log for Linux instances and C:\ProgramData\Amazon\SSM\Logs\amazon-ssm-agent.log for Windows instances.

Troubleshoot PLAs that fail with "InvalidDocument" error messages

If the listed document is incorrect, then you receive the "InvalidDocument" error message.

Run the following describe-document command to confirm that the SSM document exists in the target Region:

aws ssm describe-document --name example-document-name --region us-east-1

Note: Replace example-document-name with your SSM document name and us-east-1 with your Region.

If the document is missing, then create the SSM document. If the document exists, then check the post-launch template configuration for typos in the document name. If you use a shared SSM document, then make sure that you shared the document with the target account.

Troubleshoot PLAs that fail with "Timed Out" error messages

If the PLA runs for longer than the timeout settings that you configured, then you receive "Timed out" error messages.

Check the Run command status for each command. Compare the command's timeout setting with the actual run time. If the run time exceeds the timeout settings, then increase the timeout value in the SSM document or post-launch template.

Also, confirm that all scripts in the SSM document are non-interactive. Scripts that use prompts, such as read in Linux or Read-Host in PowerShell, cause timeouts.

Review the SSM Agent logs to identify and troubleshoot crashes.

Add timeout handling to individual commands in your scripts. For example, use the timeout command in Linux or Start-Process -Wait with a timeout value in PowerShell. If a specific command in your script is stuck, then the PLA might time out without a clear error message. With timeout handling, you can clearly identify what command caused the PLA to fail.

Troubleshoot PLAs that succeed but don't apply the expected changes

If the PLA shows "Success" but the expected changes weren't applied, then complete the following steps:

  1. Review the Run Command status details.
  2. Open the Systems Manager console.
  3. Choose Documents, and then check the SSM document. Make sure that the OS in the precondition matches the target OS.
  4. Check the error handling logic of your scripts. For Linux, use set -e so that the scripts exits if there are errors. For Windows, use $ErrorActionPreference = "Stop" so that the script stops if there are errors.

Related information

Post-launch template (AWS Transform MGN)

Post-launch settings (Elastic Disaster Recovery)

Step 1: Complete Session Manager prerequisites