Auto-snapshot AWS Lightsail every Monday, Wednesday, and Friday

0

I am currently using the AWS Lightsail service and I would like to set up an auto-snapshot,

but I only want it to occur on Mondays, Wednesdays, and Fridays.

In the picture below i can only set daily.

Can someone please assist me with the steps to achieve this?

Any help would be greatly appreciated.

aws

  • Please let me know if I answered your question and select my answer. Thank you

質問済み 1年前252ビュー
1回答
0

To set up an auto-snapshot in AWS Lightsail on specific days of the week, you'll need to use a combination of AWS CloudWatch Events and AWS Lambda. Here are the steps to achieve this:

Create a new Lambda function: First, create a new Lambda function in the AWS Management Console. You can choose any runtime you like, but we recommend using Python, as it's easy to work with and has good support for AWS SDKs.

Configure the function: Once the function is created, you'll need to configure it to take a snapshot of your Lightsail instance. Here's some sample Python code to get you started:

import boto3

def lambda_handler(event, context): client = boto3.client('lightsail') response = client.create_instance_snapshot( instanceSnapshotName='YourSnapshotName', instanceName='YourInstanceName' )

This code will create a new snapshot of your Lightsail instance with the given name.

Create a CloudWatch event rule: Next, you'll need to create a CloudWatch event rule that triggers your Lambda function on the days you want to take a snapshot. Here's some sample JSON code to get you started:

{ "scheduleExpression": "cron(0 0 ? * MON,WED,FRI *)", "targets": [ { "arn": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME", "id": "MyTarget" } ] }

This code will trigger your Lambda function at 12:00am UTC on Mondays, Wednesdays, and Fridays. Be sure to replace REGION, ACCOUNT_ID, and FUNCTION_NAME with the appropriate values.

Test the setup: Finally, test the setup by waiting for the scheduled time to arrive and checking if a new snapshot has been created. You can also check the CloudWatch Logs for your Lambda function to see if there were any errors. That's it! With these steps, you can set up an auto-snapshot in AWS Lightsail on specific days of the week. Please let me know if that answered your question.

AWS
エキスパート
ZJon
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ