Re: invoke ssm automation from ec2 in private subnet

0

Hi,

can we invoke ssm automation from .sh script running on ec2 instance in private subnet. If this is possible, we can avoid creating gateway endpoint for each region to update dynamodb table as well as to perform s3 related operations.

I am thinking if ssm agent is able to talk to ssm service, can we leverage ssm agent someway to trigger ssm automation to execute .py script to perform ddb , s3 related operations.

Regards

1 Answer
0

Hello.

If you are running EC2 in a private subnet, you can use Systems Manager functionality by creating a NAT Gateway or a VPC endpoint as described in the document below.
However, if you are accessing S3 or DynamoDB from EC2, you will also need to create a VPC endpoint for S3 or DynamoDB.
https://docs.aws.amazon.com/systems-manager/latest/userguide/setup-create-vpc.html

Also, if you are running Automation, I think it is possible to call it from Lambda or Eventbridge scheduler instead of from EC2, so you may want to consider using this.
https://docs.aws.amazon.com/systems-manager/latest/userguide/running-automations-event-bridge.html

profile picture
EXPERT
answered 5 months ago
  • Hello, thanks for response. I want to run sh script to perform admin functions on ec2. So I have master sh script which is invoked by ssm run command, then master script downloads actual script from s3 and pass control to that script and at the end, update ddb to store status.

    I am thinking if ssm agent is able to talk to ssm service, then it sbould be possible to execute ssm automation from awwcli commands within ec2.

    I searched additionally, there is command to execute or invoke ssm automation , I am going to try that.

    Purpose is to avoid gateway endpoint as it is region specific and interace Endpoint has cost

  • To use the ssm run command to run scripts in EC2, EC2 must be registered as a managed instance in Systems Manager. To register as a managed instance, SSM Agent must be able to communicate with Systems Manager, so if you are running EC2 in a private subnet, you will need to configure a NAT Gateway or VPC endpoint.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions