Skip to content

Lambda - Invoke SSM document

#week_nine - Invoke SSM Document by Lambda


duration: 1 week

ForgTech company wanna test your ability to type down a clean code by Deploying the structure of resources. This will help you to build a good reputation.

FrogTech intends to use CloudWatch to invoke Lambda Python Function that triggers SSM shell document in order to automate common mitigation response. you have requested to deploy a Lambda Python function that triggers an SSM Shell document that restarts SSH service, besides deploying a temp EC2 machine testing The trigger functionality.

FrogTech is required to use high-level HCL language techniques, by using if conditions allow users to input the resource tag values else insert a random value instead, use local variables to combine common tags, and use one package zip file that includes all function library dependencies and do NOT use AWS native libraries (i.e. insert the zip package directly to you HCL code Or upload it manually into an S then mention it into you HCL code )

Use IaC Terraform to build all resources and consider the below requirements specifications.

  1. Resources must be created at the us-east-1 region.
  2. Resources must have common tags combination as below:
  3. Common tags:
    • Key: “Environment”, Value: “terraformChamps”
    • Key: “Owner”, Value: <“Your_first_name“>
  4. Create & Share a document that Explains what you learn.
  5. Build an Architecture diagram of the deployment resources.


SSM AWS-RunShellScript example

{
  "schemaVersion": "2.2",
  "description": "Use this document to deploy and configure Linux Servers",
  "mainSteps": [
    {
      "action": "aws:runShellScript",
      "name": "runShellScript",
      "precondition": {
        "StringEquals": [
          "platformType",
          "Linux"
        ]
      },
      "inputs": {
        "runCommand": [
          "#!/bin/bash",
          "mkdir /testDir",
          "touch /testDir/testFile"
        ]
      }
    }
  ]
}


References: