fix:変数名の変更

This commit is contained in:
shibata.r 2022-10-13 16:50:32 +09:00
parent d18f260ed1
commit c722349db3

View File

@ -3,8 +3,8 @@ import os
#環境変数
client = boto3.client('rds')
TAGKEY = os.environ['TAGKEY']
TAGVALUE = os.environ['TAGVALUE']
AUTO_STOP_TAG_TAGKEY = os.environ['TAGKEY']
AUTO_STOP_ENABLE = os.environ['TAGVALUE']
def lambda_handler(event, context):
#クラスターを停止
@ -13,7 +13,7 @@ def lambda_handler(event, context):
if cluster['Status'] == "available":
tags = client.list_tags_for_resource(ResourceName=cluster['DBClusterArn'])
for tag in tags['TagList']:
if tag['Key'] == TAGKEY and tag['Value'] == TAGVALUE:
if tag['Key'] == AUTO_STOP_TAG_TAGKEY and tag['Value'] == AUTO_STOP_ENABLE:
client.stop_db_cluster(DBClusterIdentifier=cluster['DBClusterIdentifier'])
#インスタンスを停止
@ -22,6 +22,6 @@ def lambda_handler(event, context):
if instance['DBInstanceStatus'] == "available":
tags = client.list_tags_for_resource(ResourceName=instance['DBInstanceArn'])
for tag in tags['TagList']:
if tag['Key'] == TAGKEY and tag['Value'] == TAGVALUE:
if tag['Key'] == AUTO_STOP_TAG_TAGKEY and tag['Value'] == AUTO_STOP_ENABLE:
client.stop_db_instance(DBInstanceIdentifier=instance['DBInstanceIdentifier'])