- Newest
- Most votes
- Most comments
The issue you're experiencing with EventBridge and the "Invalid input for target" error message when trying to run a Systems Manager Document is likely due to a mismatch between the input format expected by the Systems Manager Document and the input provided by EventBridge.
Based on your setup, there are a few potential issues:
-
Input Transformer: Your input transformer is correctly extracting the EC2 instance ID, but it's wrapping it in a JSON object. Systems Manager might be expecting a different format.
-
Target Configuration: The "Target Key" you've set as "InstanceIds" suggests you're trying to use the EC2 Run Command target type, which has specific input requirements.
-
Document Parameters: Your Systems Manager Document expects a parameter named "instanceId", but the way you're providing this parameter might not be correct.
To resolve this issue, try the following:
-
Modify your Input Transformer template to match the exact format expected by Systems Manager. Instead of:
{ "instanceId": "<instanceId>" }
Try using:
{ "InstanceIds": ["<instanceId>"] }
-
In the EventBridge rule target configuration, make sure you're using the "AWS Systems Manager Run Command" target type, not the generic "AWS Systems Manager" type.
-
If you're using the Run Command target type, you don't need to specify the instance ID in the input transformer. Instead, use the "InstanceIds" field in the target configuration to specify the instance ID dynamically.
-
Ensure that the IAM role associated with your EventBridge rule has the necessary permissions to invoke the Systems Manager Document and perform actions on the target EC2 instances.
-
Double-check that your Systems Manager Document is correctly formatted and that the parameter names in the document match the input you're providing.
If these steps don't resolve the issue, you may need to review the EventBridge rule configuration and Systems Manager Document in more detail to ensure they're properly aligned.
Sources
Event bus targets in Amazon EventBridge - Amazon EventBridge
Troubleshoot Amazon EventBridge rule with ECS | AWS re:Post
Amazon EventBridge input transformation - Amazon EventBridge
Relevant content
asked 3 years ago
