I am configuring lambda function to Start/Stop Ec2 instance from the aws doc https://repost.aws/knowledge-center/start-stop-lambda-eventbridge but i am geeting below error while test the code.
"errorMessage": "Could not connect to the endpoint URL: "https://ec2.us-east-2c.amazonaws.com/""
import boto3
region = 'us-east-2c'
instances = ['i-081929e311352ba0c']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
I am not able to find the doc related to the issue. Please help what i am doing wrong.
The error message you're encountering suggests there's an issue with the endpoint URL. The region name you provided seems incorrect. AWS regions typically follow the format us-east-2, us-east-2c is not a valid region name.