AWS CDK中的CfnAccount资源给出NoClassDefFoundError

时间:2019-04-02 13:06:13

标签: java aws-cdk

当我尝试添加Cloudwatch角色以通过aws-cdk将日志写入我的Api-Gateway时,出现了NoClassDefFoundError。我在做什么错了?

我添加了一个角色,该角色具有在部署时没有错误的必要权限。

我的角色:

Role apiGwLogRole = new Role(this, "api-gw-log-role", RoleProps.builder()
                .withAssumedBy(new ServicePrincipal("apigateway.amazonaws.com"))
                .withRoleName("api-gw-cw-logs")
                .build());
        apiGwLogRole.attachManagedPolicy("arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs");

之后,我尝试将角色添加到api-gw帐户,如下所示:

new CfnAccount(this, "cfn-account", CfnAccountProps.builder()
                .withCloudWatchRoleArn(apiGwLogRole.getRoleArn())
                .build());

但是当我尝试比较时,它给了我

java.lang.NoClassDefFoundError: software/amazon/awscdk/CfnResource
...
An exception occured while executing the Java class. software/amazon/awscdk/CfnResource: software.amazon.awscdk.CfnResource

我尝试复制此CFN指令: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-account.html

但是显然我做错了。如果有人能指出正确的方向,我将不胜感激。

0 个答案:

没有答案