fix:変数名の変更
This commit is contained in:
parent
d18f260ed1
commit
c722349db3
@ -3,8 +3,8 @@ import os
|
|||||||
|
|
||||||
#環境変数
|
#環境変数
|
||||||
client = boto3.client('rds')
|
client = boto3.client('rds')
|
||||||
TAGKEY = os.environ['TAGKEY']
|
AUTO_STOP_TAG_TAGKEY = os.environ['TAGKEY']
|
||||||
TAGVALUE = os.environ['TAGVALUE']
|
AUTO_STOP_ENABLE = os.environ['TAGVALUE']
|
||||||
|
|
||||||
def lambda_handler(event, context):
|
def lambda_handler(event, context):
|
||||||
#クラスターを停止
|
#クラスターを停止
|
||||||
@ -13,7 +13,7 @@ def lambda_handler(event, context):
|
|||||||
if cluster['Status'] == "available":
|
if cluster['Status'] == "available":
|
||||||
tags = client.list_tags_for_resource(ResourceName=cluster['DBClusterArn'])
|
tags = client.list_tags_for_resource(ResourceName=cluster['DBClusterArn'])
|
||||||
for tag in tags['TagList']:
|
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'])
|
client.stop_db_cluster(DBClusterIdentifier=cluster['DBClusterIdentifier'])
|
||||||
|
|
||||||
#インスタンスを停止
|
#インスタンスを停止
|
||||||
@ -22,6 +22,6 @@ def lambda_handler(event, context):
|
|||||||
if instance['DBInstanceStatus'] == "available":
|
if instance['DBInstanceStatus'] == "available":
|
||||||
tags = client.list_tags_for_resource(ResourceName=instance['DBInstanceArn'])
|
tags = client.list_tags_for_resource(ResourceName=instance['DBInstanceArn'])
|
||||||
for tag in tags['TagList']:
|
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'])
|
client.stop_db_instance(DBInstanceIdentifier=instance['DBInstanceIdentifier'])
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user