https://pulumi.com logo
#aws
Title
# aws
c

calm-horse-33012

09/30/2022, 8:31 AM
Hi, I was looking into how to configure the LogGroup used under-the-hood by API Gateway, and I fell over this in the documentation: https://www.pulumi.com/registry/packages/aws/api-docs/apigateway/stage/#managing-the-api-logging-cloudwatch-log-group Is there some magic happening here with the dependsOn? From my understanding it isn't possible to configure the LogGroup API Gateway uses, and it goes by the convention:
API-Gateway-Execution-Logs-<apiId>/<stage>
, so I'm not sure what the dependsOn is supposed to achieve except creating a LogGroup prior to the stage? 🤔
l

little-soccer-5693

09/30/2022, 4:13 PM
i don't think the dependsOn is necessary. i just checked my usage and I'm not using it. here's some boilerplate you might find helpful:
Copy code
const ApiGwStageAccessLogFmt = "$context.identity.sourceIp - - [$context.requestTime] \"$context.httpMethod $context.routeKey $context.protocol\" sts:$context.status len:$context.responseLength reqId:$context.requestId lambdasts:$context.integrationStatus integErr:$context.integrationErrorMessage errMsg:$context.error.message"

       accessLogGroup, err := cw.NewLogGroup(ctx, "myproject-apigw-acccess-logs",
                &cw.LogGroupArgs{})
        if err != nil {
                return err
        }

        accessLogArgs := &gateway2.StageAccessLogSettingsArgs{
                DestinationArn: accessLogGroup.Arn,
                Format:         pulumi.String(ApiGwStageAccessLogFmt),
        }

        stageArgs := &gateway2.StageArgs{
                AccessLogSettings: accessLogArgs,
                ApiId:             apiGw.ID(),
                AutoDeploy:        pulumi.Bool(true),
                Description:       pulumi.Sprintf("prod stage for MyProject"),
                Name:              pulumi.String("prod"),
        }

        stage, err := gateway2.NewStage(ctx, "myproject-apigw-stage", stageArgs)
        if err != nil {
                return err
        }