def confirm_subscription(self, confirmation_data: dict): self.logger.info("START: confirm_subscription") token = confirmation_data["Token"] arn = confirmation_data["TopicArn"] self.logger.info("Confirm SNS Arn: {}".format(arn)) sns = Sns(arn=arn) sns.confirm_subscription(token) self.logger.info("END: confirm_subscription")
def verify_sns_notification(self, notification_data: dict): self.logger.info("START: verify_sns_notification") verify = Sns.verify_notification(notification_data) self.logger.info("Verify Result: {}".format(verify)) if not verify: raise InvalidNotificationException(notification_data) self.logger.info("END: verify_sns_notification")
def save_monitor(self, request_user: UserModel, resource: Resource, aws: AwsEnvironmentModel) -> Resource: self.logger.info("START: save_monitor") # 使用できるAWSアカウントか if not request_user.has_aws_env(aws): raise PermissionDenied( "request user can't use aws account. user_id: {}, aws_id: {}". format(request_user.id, aws.id)) # SNS連携許可 self.logger.info("sns add permission... aws: {}".format(aws.id)) sns = Sns(resource.region) sns.add_permission(aws) self.logger.info("sns add permission... DONE") # アラーム作成 self.logger.info("cloudwatch put metric alarms ...") CloudWatch(aws, resource.region).put_metric_alarms(resource, sns.arn) self.logger.info("cloudwatch put metric alarms ... DONE") self.logger.info("END: save_monitor") return resource