如何获取 AWS-CDK 交付流构造的 ARN

How to get the ARN of an AWS-CDK delivery stream construct

我正在创建 CfnDeliveryStream in CDK and I would like to use the ARN later in an IAM role. I found the attribute attrArn, but it is undocumented. My question is: how do I access the ARN of a delivery stream (similar to what is available in S3 constructs).

谢谢, 本尼

您可以使用以下语法 -

const resourceARN = cdk.Fn.getAtt(%ID_YOU_WANT_TO_GET%, "Arn").toString();

用法:

    const lambdaFunction = new sam.CfnFunction(scope, "myLambdaID", {
      functionName: name,
      runtime: 'nodejs10.x',
      codeUri: {
        bucket: lambdaAssest.s3BucketName,
        key: lambdaAssest.s3ObjectKey
      },
      handler: handler,
      timeout: timeout,
      autoPublishAlias : `current`
    });

    const lambdaARN = cdk.Fn.getAtt( lambdaFunction.logicalId, "Arn").toString();

要验证 ARN,请使用 cdk.CfnOutput -

new cdk.CfnOutput(scope, `output-arn`, { value: lambdaARN });