我正在使用 CDK Python API 来定义 Glue 爬虫,但是,CDK 生成的模板在 Crawler 资源中包含空的“目标”块。
我一直无法找到一个可以效仿的例子。我尝试改变目标对象的定义,但对象定义似乎被 CDK 忽略了。
from aws_cdk import cdk
BUCKET='poc-1-bucket43879c71-5uabw2rni0cp'
class PocStack(cdk.Stack):
def __init__(self, app: cdk.App, id: str, **kwargs) -> None:
super().__init__(app, id)
from aws_cdk import (
aws_iam as iam,
aws_glue as glue,
cdk
)
glue_role = iam.Role(
self, 'glue_role',
assumed_by=iam.ServicePrincipal('glue.amazonaws.com'),
managed_policy_arns=['arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole']
)
glue_crawler = glue.CfnCrawler(
self, 'glue_crawler',
database_name='db',
role=glue_role.role_arn,
targets={"S3Targets": [{"Path": f'{BUCKET}/path/'}]},
)
我希望生成的模板包含具有单个 S3Target 的有效“目标”块。但是,cdk synth
在 AWS::Glue::Crawler 资源中输出一个带有空目标的模板:
gluecrawler:
Type: AWS::Glue::Crawler
Properties:
DatabaseName: db
Role:
Fn::GetAtt:
- glueroleFCCAEB57
- Arn
Targets: {}