- Newest
- Most votes
- Most comments
The error you're encountering is due to the way the "Subject" parameter is being handled in your AWS Systems Manager document. The issue arises because you've defined "Subject" as an optional parameter, but you're always including it in the SNS Publish API call, even when it might not be provided.
When the "Subject" parameter is not provided, the Systems Manager document tries to pass an empty or null value for the "Subject" to the SNS Publish API, which results in the "Invalid parameter: Subject" error.
To resolve this issue, you should modify your document to only include the "Subject" in the API call when it's actually provided. You can do this by using the "aws:executeAwsApi" action's ability to conditionally include parameters.
Here's how you can modify the "inputs" section of your "aws:executeAwsApi" step:
"inputs": { "Service": "sns", "Api": "Publish", "TopicArn": "{{TopicArn}}", "Message": "{{Message}}", "Subject": "{{ Subject | default('') | trim | length > 0 ? Subject : omit }}" }
This modification uses a conditional expression to only include the "Subject" parameter if it has a non-empty value. If "Subject" is not provided or is an empty string, it will be omitted from the API call entirely.
By making this change, your Systems Manager document should work correctly whether or not a "Subject" is provided, avoiding the "Invalid parameter: Subject" error.
Sources
AWS Service Catalog Service Actions - AWS Service Catalog
SendCommand - AWS Systems Manager
Relevant content
- AWS OFFICIALUpdated 3 years ago
