1回答
- 新しい順
- 投票が多い順
- コメントが多い順
2
Hello.
Please change the code as below.
The change is "rds_client = client('rds')" on the third line.
It's happening because a variable named client is already used in boto3's client function to create an RDS client.
So, setting different variable names for RDS client and SES client will resolve the error.
#!/usr/bin/env python3
from boto3 import client
rds_client = client('rds')
def lambda_handler(event, context):
rds_instances = rds_client.describe_db_instances(Filters=[{'Name':'engine', 'Values':['oracle-ee']}])
#print out just the number of instances
print(len(rds_instances['DBInstances']))
#print out the engine
if len(rds_instances['DBInstances']) != 0:
for db_instance in rds_instances['DBInstances']:
db_engine = db_instance.get('Engine')
print(db_engine)
#Send email for result. This is where code fails after adding this section.
ses_client = client("ses")
subject = "Report"
body = "Need to add the output of two print statements above with a title for each"
message = {"Subject": {"Data":subject}, "Body":{"Html":{"Data": body}}}
response = ses_client.send_email(Source = "mike10@gmail.com",
Destination={"ToAddresses": ["mike10@gmail.com"]},
Message = message)
return response
関連するコンテンツ
- AWS公式更新しました 1年前
- AWS公式更新しました 2年前