aws / aws/aws-cdk

aws-mwaa: CfnEnvironment logging configuration required parameters set to optional

Open
#30,645 3 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-mwaa bug effort/medium needs-cfn p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

When trying to instantiate a new `CfnEnvironment` with logging configuration set to the following:

```
loggingConfiguration: {
taskLogs: {enabled: false},
webserverLogs: {enabled: false},
schedulerLogs: {enabled: false},
workerLogs: {enabled: false},
dagProcessingLogs: {enabled: false}
}
```

I get an error when running CDK deploy:

```
4:23:16 pm | CREATE_FAILED | AWS::MWAA::Environment | MwaaEnvironment
Resource handler returned message: "Invalid request provided: 5 validation errors detected: Value null at 'loggingConfiguration.schedulerLogs.logLevel' failed to satisfy constraint: Member must not be null; Value null at 'loggingConfigur
ation.dagProcessingLogs.logLevel' failed to satisfy constraint: Member must not be null; Value null at 'loggingConfiguration.webserverLogs.logLevel' failed to satisfy constraint: Member must not be null; Value null at 'loggingConfigurati
on.workerLogs.logLevel' failed to satisfy constraint: Member must not be null; Value null at 'loggingConfiguration.taskLogs.logLevel' failed to satisfy constraint: Member must not be null (Service: Mwaa, Status Code: 400, Request ID: 916
```

The error is due to the `logLevel` attribute not being passed into the logging options. The following fixes the issue:

```
loggingConfiguration: {
taskLogs: {enabled: false, logLevel: 'INFO'},
webserverLogs: {enabled: false, logLevel: 'INFO'},
schedulerLogs: {enabled: false, logLevel: 'INFO'},
workerLogs: {enabled: false, logLevel: 'INFO'},
dagProcessingLogs: {enabled: false, logLevel: 'INFO'},
}
```

The issue is that that `logLevel` is not a required parameter according to the TypeScript interface:
```
/**
* Defines the Apache Airflow logs to send for the log type (e.g. `DagProcessingLogs` ) to CloudWatch Logs. Valid values: `CRITICAL` , `ERROR` , `WARNING` , `INFO` .
*
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-mwaa-environment-moduleloggingconfiguration.html#cfn-mwaa-environment-moduleloggingconfiguration-loglevel
*/
readonly logLevel?: string;
```

### Expected Behavior

CDK should either:

- Allow me to exclude a `logLevel` (since I've disabled logging anyway) and deploy the instance of MWAA
or
- Force me to provide a `logLevel`

### Current Behavior

Error message asking me to provide the `logLevel`

### Reproduction Steps

```
const mwaaEnvironment = new mwaa.CfnEnvironment(this, "MwaaEnvironment", {
name: 'MyMwaaEnvironment',
airflowVersion: '2.0.2',
environmentClass: 'mw1.small',
maxWorkers: 1,
minWorkers: 1,
dagS3Path: 'dags',
sourceBucketArn: {some bucket arn},
executionRoleArn: {some role arn},
requirementsS3Path: 'requirements.txt',
pluginsS3Path: "plugins.zip",
networkConfiguration: {
securityGroupIds: [securityGroup.securityGroupId],
subnetIds: vpc.selectSubnets({subnetType: ec2.SubnetType.PUBLIC}).subnetIds.slice(0, 2)
},
webserverAccessMode: 'PUBLIC_ONLY',
loggingConfiguration: {
taskLogs: {enabled: false, logLevel: 'INFO'},
webserverLogs: {enabled: false},
schedulerLogs: {enabled: false},
workerLogs: {enabled: false},
dagProcessingLogs: {enabled: false},
}
});
```

### Possible Solution

Provide a `logLevel`

### Additional Information/Context

_No response_

### CDK CLI Version

2.145.0 (build fdf53ba)

### Framework Version

_No response_

### Node.js Version

v22.0.0

### OS

osx

### Language

TypeScript

### Language Version

v10.9.2

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the CfnEnvironment loggingConfiguration type, especially the five log-level properties, and compare it with the validation errors from the AWS MWAA deployment. Confirm the intended behavior for omitted logLevel values, then verify that the TypeScript interface and the deployment reproduction agree with that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.