Skip to content

Instantly share code, notes, and snippets.

@auroris
Last active July 14, 2023 19:01
Show Gist options
  • Save auroris/f7a61352cfa753c6332cf9ad59fe12b8 to your computer and use it in GitHub Desktop.
Save auroris/f7a61352cfa753c6332cf9ad59fe12b8 to your computer and use it in GitHub Desktop.
For "Scaling your Migration Operations" we're using Systems Manager (SSM) which is not really something we covered in class.
On the left navigation, locate "Documents" at the bottom of the menu, then access the "Owned by me" tab.
For the first task, we're modifying ConfigureProxy. This YAML document is trying to run powershell commands on linux, and
linux commands on windows, and that is not desired behavior. There's two sections, one for Linux and one for windows and We
can trivially restrict the "inputs:" section with the following code:
precondition:
StringEquals:
- platformType
- Windows
In YAML, spacing is significant, kind of like Python. We specify Windows for the windows section and Linux for the
linux-specific section. We can find information about preconditions in
https://docs.aws.amazon.com/systems-manager/latest/userguide/documents-schemas-features.html
For the second task, the YAML document contains an example we can copy and paste from. Here is my answer, just insert it
into the appropriate place according to the instructions. It's just a copy/paste of the run_patch section with some stuff
changed; your document name will be different due to random generation of nonsense:
- inputs:
InstanceIds:
- '{{InstanceId}}'
DocumentName: LabStack-prewarm-1c28d06d-0798-4c88-bd5f-fd00c4736ad7-4R3jgJq245AHarzuTJAXFQ-3-ConfigureProxy-eU57BmyFXgpx
name: configure_proxy
action: 'aws:runCommand'
For the last task, we need to go to Amazon EventBridge and we're going to the Buses -> Rules page. Click the edit button,
go to step 3, and edit the Input path, which is set to:
{
"instanceid": "$.detail.requestParameters.resourcesSet"
}
When using JSON Path Finder, it will provide you with a JSON path that looks like: "x.detail.requestParameters.resourcesSet.items[0].resourceId"
We replace "x" with "$", and because AWS might return more than 1 object in the items[] array, AWS specifies we use
a "*" to indicate such. So the final string is:
{
"instanceid": "$.detail.requestParameters.resourcesSet.items[*].resourceId"
}
Update the rule and the task is done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment