(opensearchservice): must configure zone awareness settings even when i am not enabling zone awareness
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When creating an opensearch domain using AWS CDK, I am getting the following error:
`Invalid request provided: You must configure zone awareness settings if you turn on zone awareness`
My CDK code is as follows:
```typescript
import * as cdk from "aws-cdk-lib";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
import { Construct } from "constructs";
export interface OpenSearchProps {
vpc: ec2.IVpc;
subnets: ec2.ISubnet[];
}
export class OpenSearch extends Construct {
constructor(scope: Construct, id: string, props: OpenSearchProps) {
super(scope, id);
...
const opensearchDomain = new opensearch.Domain(this, "Domain", {
vpc,
vpcSubnets: [
{
subnets,
},
],
securityGroups: [securityGroup],
version: opensearch.EngineVersion.OPENSEARCH_2_5,
tlsSecurityPolicy: opensearch.TLSSecurityPolicy.TLS_1_2,
enableVersionUpgrade: true,
removalPolicy: cdk.RemovalPolicy.DESTROY,
zoneAwareness: {
enabled: false,
},
capacity: {
dataNodeInstanceType: "t3.small.search",
dataNodes: 1,
},
});
}
}
```
I've also tried with omitting `zoneAwareness` altogether
### Expected Behavior
The cluster should be deployed in a single AZ
### Current Behavior
There is an error stating that zone awareness must be configured, even tho my zone awareness is set to false
### Reproduction Steps
Create a CDK stack
```typescript
export class MyStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// VPC
const vpcId = this.node.tryGetContext("vpcId");
const vpc = ec2.Vpc.fromLookup(this, "Vpc", { vpcId });
const subnets = vpc.privateSubnets;
const subnetIds = vpc.privateSubnets.map((subnet) => subnet.subnetId);
// OpenSearch
const opensearch = new OpenSearch(this, "OpenSearch", {
vpc,
subnets,
});
}
}
```
```typescript
import * as cdk from "aws-cdk-lib";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
import { Construct } from "constructs";
export interface OpenSearchProps {
vpc: ec2.IVpc;
subnets: ec2.ISubnet[];
}
export class OpenSearch extends Construct {
constructor(scope: Construct, id: string, props: OpenSearchProps) {
super(scope, id);
const { vpc, subnets } = props;
const securityGroup = new ec2.SecurityGroup(this, "SecurityGroup", {
vpc,
allowAllOutbound: true,
});
securityGroup.addIngressRule(
ec2.Peer.ipv4(vpc.vpcCidrBlock),
ec2.Port.tcp(9200)
);
securityGroup.addIngressRule(
ec2.Peer.ipv4(vpc.vpcCidrBlock),
ec2.Port.tcp(9300)
);
const opensearchDomain = new opensearch.Domain(this, "Domain", {
vpc,
vpcSubnets: [
{
subnets,
},
],
securityGroups: [securityGroup],
version: opensearch.EngineVersion.OPENSEARCH_2_5,
tlsSecurityPolicy: opensearch.TLSSecurityPolicy.TLS_1_2,
enableVersionUpgrade: true,
removalPolicy: cdk.RemovalPolicy.DESTROY,
zoneAwareness: {
enabled: false,
},
capacity: {
dataNodeInstanceType: "t3.small.search",
dataNodes: 1,
},
});
new cdk.CfnOutput(this, "Endpoint", {
value: opensearchDomain.domainEndpoint,
});
}
}
```
### Possible Solution
Downgrading to CDK version `2.85.0` seems to fix the problem
### Additional Information/Context
_No response_
### CDK CLI Version
2.117.0 (build 59d9b23)
### Framework Version
2.127.0
### Node.js Version
v21.6.2
### OS
macos
### Language
TypeScript
### Language Version
5.3.3
### Other information
_No response_
Contributor guide
Research direction
Reproduce the AWS CDK OpenSearch Domain configuration using the provided TypeScript examples and compare versions 2.85.0, 2.117.0, and 2.127.0. Inspect the synthesized configuration for zone awareness and confirm that the corrected behavior deploys a single-AZ domain when zone awareness is disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100