ããã«ã¡ã¯ãæè¡ä¸èª²ã®å±±ä¸ã§ãã
å æ¥ç¤¾å ã®ã¡ã³ãã¼ãã以ä¸ç¸è«ãåãã¾ããã
ãå±±ä¸ããã Amazon Connect 詳ããã§ãããï¼ ä½ãã¤ã³ã¹ã¿ã³ã¹ã«é害ãèµ·ããã¨ãã«é»è©±ã§éç¥ããã¨ãã§ãããã§ããï¼ãï¼å¤åãããªããã ãã§ããããããªãã§ããï¼ã
ã¨ãããã¨ã§ãAmazon Connect ã¯ãã¥ã¼ããªã¢ã«ä»¥å¤è§¦ã£ããã¨ããªãã£ãã®ã§ãå®éã«é»è©±ãããããã®ãæ¤è¨¼ãã¦ã¿ã¾ããã
ã¯ããã«
ä½ãã¤ã³ã¹ã¿ã³ã¹ã«é害ãçºçããéã«ã CloudWatch çã§æ¤ç¥ããä»çµã¿ãããã°ããããããªã¬ã¼ã« Lambda ãã¡ã³ã¯ã·ã§ã³ãããã¯ã§ããã®ã§ã Lambda ãã Amazon Connect çµç±ã§é»è©±éç¥ãã§ããã°ããã¨èãã Lambda ãã Connect ã§é»è©±ãããã¨ãç®æ¨ã¨ãã¾ããã
Amazon Connect ã¨ã¯
Amazon Connect ã¯ç°¡åã«ä½¿ããã¯ã©ã¦ãåã³ã³ã¿ã¯ãã»ã³ã¿ã¼ã§ãã 詳ããã¯ãã¡ããã覧ãã ããã å ¬å¼ãµã¤ã Amazon Connect å®å¿ãã¦éç¨ãã§ãããçã£ã¦èª¿ã¹ã¦ã¿ã Amazon Connect å°å ¥æ¯æ´è³æãå ¬éãã¾ãã Amazon Connectã§é»è©±ãã¤ãªã
ã³ã¼ã«ã»ã³ã¿ã¼ãµã¼ãã¹ã®ç«ã¡ä¸ã
Amazon Connect ãã³ãºãªã³åç´ç·¨ ãè¦ãªãããã³ã¼ã«ã»ã³ã¿ã¼ãµã¼ãã¹ãç«ã¡ä¸ãã¾ãã
åãåããããã¼ã®ä½æ
ä»å以ä¸ã®ãããªããã¼ãä½æãã¾ããã ãããã·ã³ãã«ã§ãããã
ããã§ã®ãã¤ã³ãã¯ã¦ã¼ã¶ã¸ã®å¿çã Lambda ããåãåã£ãã¡ãã»ã¼ã¸ã¨ãããã®ã§ã以ä¸ã®ããã«ãããã³ããã®åçãã§å±æ§ãæå®ããå¿ è¦ãããã¾ãã
ããã¼ãä½æãããã 以ä¸ã®ãã㪠ARN ãçºè¡ããã¾ãã®ã§ã ã¤ã³ã¹ã¿ã³ã¹ ID
㨠ã³ã³ã¿ã¯ãããã¼ ID
ãæ§ãã¦ããã¦ãã ããã
arn:aws:connect:ap-southeast-2:000000000000:instance/[ã¤ã³ã¹ã¿ã³ã¹ ID]/contact-flow/[ã³ã³ã¿ã¯ãããã¼ ID]
Lambda ãã¡ã³ã¯ã·ã§ã³ã®ä½æ
ä½æãã Lambda ãã¡ã³ã¯ã·ã§ã³ã¯ãã¡ã
DestinationPhoneNumber
ã«ã¯é»è©±ããããé»è©±çªå·ãã SourcePhoneNumber
ã«ã¯ Amazon Connect ã§åå¾ããé»è©±çªå·ãå
¥åãã¾ãã
import boto3
ec2 = boto3.client('ec2', region_name='ap-northeast-1')
connect = boto3.client('connect')
def lambda_handler(event, context):
running_instances = get_running_instance()
message = 'ç¾å¨ç¨¼åä¸ã®ã¤ã³ã¹ã¿ã³ã¹ã¯'
if running_instances:
for instance_name in running_instances:
message += instance_name
message += 'ã§ã'
else:
message += 'ããã¾ãã'
call(message)
# Amazon Connect ã§é»è©±ãããã
def call(message):
connect.start_outbound_voice_contact(
DestinationPhoneNumber='+819000000000',
ContactFlowId=[ã³ã³ã¿ã¯ãããã¼ ID],
InstanceId=[ã¤ã³ã¹ã¿ã³ã¹ ID],
SourcePhoneNumber='+815000000000',
Attributes={
'message': message
}
)
# 稼åä¸ã®ã¤ã³ã¹ã¿ã³ã¹ä¸è¦§ãåå¾
def get_running_instance():
response = ec2.describe_instances(
Filters=[
{
'Name': 'instance-state-name',
'Values': [
'running',
]
},
],
)
if not response['Reservations']:
return []
running_instances = []
for reservation in response['Reservations']:
reservation['Instances'][0]
running_instances += [tag['Value'] for tag in reservation['Instances'][0]['Tags'] if tag['Key'] == 'Name']
return running_instances
ä½æãã Lambda ããã¹ãå®è¡ããã¨ã Mizuki ãããæ±äº¬ãªã¼ã¸ã§ã³ã§ç¨¼åä¸ã®ã¤ã³ã¹ã¿ã³ã¹ãé»è©±ã§ã¤ã¶ããã¦ããã¾ããï¼ ï¼å®éã«ä½¿ãã¨ãã¯ããã¡ãã£ã¨ãã£ããããã¾ã
ãããã«
Lambda ããé»è©±ãããããã£ã¦ãããã§ãããããããä¸è¨ã®æµããä½ãã®ã«æ¬å½ã« 1 æéããããããããã¾ããã§ããã Amazon Connect ã夢ãããã¾ãã