从python(lambda)中的s3事件数据中提取aws区域

时间:2016-04-18 12:12:32

标签: python json amazon-s3 aws-lambda

我尝试从s3事件数据中提取aws region参数,我已经提取了存储桶名称和密钥,但我无法获取aws区域或打印整个事件数据

source_bucket = event['Records'][0]['s3']['bucket']['name'] key_created = urllib.unquote_plus(event['Records'][0]['s3']['object']['key']).decode('utf8')

1 个答案:

答案 0 :(得分:1)

你有一个S3事件的json结构可用here

如下所示应该做的伎俩(未经测试)

18:39:02.650 [localhost-startStop-1] INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'persistenceUnit' 
Hibernate: 
drop table if exists hibernate_sequence
Hibernate: 
drop table if exists Tags
Hibernate: 
create table hibernate_sequence (
    next_val bigint
) ENGINE=InnoDB
Hibernate: 
insert into hibernate_sequence values ( 1 )
Hibernate: 
create table Tags (
    id bigint not null,
    createdDate datetime,
    desc varchar(255),
    questions varchar(255),
    seoTitle varchar(255),
    status smallint not null,
    title varchar(255),
    primary key (id)
) ENGINE=InnoDB
18:39:04.618 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'