def parse_notification_configuration(notification_config: Dict, pool=None) -> List[S3Notification]: # notification_config returned by: # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.get_bucket_notification_configuration notifications = list() arn_selectors = { "QueueConfigurations": "QueueArn", "TopicConfigurations": "TopicArn", "LambdaFunctionConfigurations": "LambdaFunctionArn", } for config_type, configs in notification_config.items(): if config_type not in arn_selectors: continue for config in configs: try: arn = config[arn_selectors[config_type]] target = EventSource.get(arn, pool=pool) notification = S3Notification(target.id) notification.target = target notifications.append(notification) except Exception as e: LOG.warning("error parsing s3 notification: %s", e) return notifications
def handle(bucket): bucket_name = bucket["Name"] if re.match(filter, bucket_name): arn = "arn:aws:s3:::%s" % bucket_name bucket = S3Bucket(arn) result.append(bucket) pool[arn] = bucket if details: try: out = s3_client.get_bucket_notification(Bucket=bucket_name) if out: if "CloudFunctionConfiguration" in out: func = out["CloudFunctionConfiguration"]["CloudFunction"] func = EventSource.get(func, pool=pool) n = S3Notification(func.id) n.target = func bucket.notifications.append(n) except Exception as e: print("WARNING: Unable to get details for bucket: %s" % e)
def handle(bucket): bucket_name = bucket['Name'] if re.match(filter, bucket_name): arn = 'arn:aws:s3:::%s' % bucket_name bucket = S3Bucket(arn) result.append(bucket) pool[arn] = bucket if details: try: out = cmd_s3api('get-bucket-notification-configuration --bucket %s' % bucket_name, env=env) if out: out = json.loads(out) if 'CloudFunctionConfiguration' in out: func = out['CloudFunctionConfiguration']['CloudFunction'] func = EventSource.get(func, pool=pool) n = S3Notification(func.id) n.target = func bucket.notifications.append(n) except Exception as e: print('WARNING: Unable to get details for bucket: %s' % e)
def handle(bucket): bucket_name = bucket['Name'] if re.match(filter, bucket_name): arn = 'arn:aws:s3:::%s' % bucket_name bucket = S3Bucket(arn) result.append(bucket) pool[arn] = bucket if details: try: s3_client = aws_stack.connect_to_service('s3') out = s3_client.get_bucket_notification(Bucket=bucket_name) if out: if 'CloudFunctionConfiguration' in out: func = out['CloudFunctionConfiguration'][ 'CloudFunction'] func = EventSource.get(func, pool=pool) n = S3Notification(func.id) n.target = func bucket.notifications.append(n) except Exception as e: print('WARNING: Unable to get details for bucket: %s' % e)