CDK deployment API Gateway - CloudWatch Logs role ARN must be set in account settings to enable logging

Viewed 2095

If you're getting the following error when you're trying to deploy an API Gateway (in particular the Stage), you'll need to ensure you have a CloudWatch ern set up against your Account.

Blah_V1Stage (V1Stage) CloudWatch Logs role ARN must be set in account settings to enable logging (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: a855c5c5-b64b-4b22-85e8-703909b4c850)

const cloudWatchRole = new iam.Role(this, this.prefix + "_cloudwatchrole",
{
    assumedBy: new iam.CompositePrincipal(new iam.ServicePrincipal("apigateway.amazonaws.com")),
    roleName: this.prefix + "_cloudwatchrole"
});
cloudWatchRole.addManagedPolicy(
    iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonAPIGatewayPushToCloudWatchLogs'))
const account = new apigateway.CfnAccount(this, "account",
    {
        cloudWatchRoleArn: cloudWatchRole.roleArn
    });
0 Answers
Related