Skip to content

Commit c1857ea

Browse files
committed
fix(searchable): enforce TLS 1.2 on OpenSearch domains (#3452)
1 parent bbcc9cb commit c1857ea

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

packages/amplify-graphql-searchable-transformer/src/__tests__/amplify-graphql-searchable-transformer.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ test('it generates expected resources', () => {
233233
ElasticsearchVersion: '7.10',
234234
DomainEndpointOptions: {
235235
EnforceHTTPS: true,
236+
TLSSecurityPolicy: 'Policy-Min-TLS-1-2-2019-07',
236237
},
237238
});
238239
Template.fromJSON(searchableStack).hasResource('AWS::Elasticsearch::Domain', {
@@ -449,6 +450,29 @@ describe('nodeToNodeEncryption transformParameter', () => {
449450
});
450451
});
451452

453+
describe('TLS security policy', () => {
454+
const schema = /* GraphQL */ `
455+
type Todo @model @searchable {
456+
content: String!
457+
}
458+
`;
459+
460+
it('synthesizes w/ TLS 1.2 security policy on the OpenSearch domain', () => {
461+
const out = testTransform({
462+
schema,
463+
transformers: [new ModelTransformer(), new SearchableModelTransformer()],
464+
});
465+
expect(out).toBeDefined();
466+
const searchableStack = out.stacks.SearchableStack;
467+
Template.fromJSON(searchableStack).hasResourceProperties('AWS::Elasticsearch::Domain', {
468+
DomainEndpointOptions: {
469+
EnforceHTTPS: true,
470+
TLSSecurityPolicy: 'Policy-Min-TLS-1-2-2019-07',
471+
},
472+
});
473+
});
474+
});
475+
452476
describe('auth', () => {
453477
const schema = /* GraphQL */ `
454478
type Todo @model @searchable {

packages/amplify-graphql-searchable-transformer/src/cdk/create-searchable-domain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TransformerContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
22
import { EbsDeviceVolumeType } from 'aws-cdk-lib/aws-ec2';
3-
import { CfnDomain, Domain, ElasticsearchVersion } from 'aws-cdk-lib/aws-elasticsearch';
3+
import { CfnDomain, Domain, ElasticsearchVersion, TLSSecurityPolicy } from 'aws-cdk-lib/aws-elasticsearch';
44
import { IRole, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
55
import { CfnParameter, Fn, RemovalPolicy } from 'aws-cdk-lib';
66
import { Construct } from 'constructs';
@@ -20,6 +20,7 @@ export const createSearchableDomain = (
2020
const domain = new Domain(stack, OpenSearchDomainLogicalID, {
2121
version: { version: '7.10' } as ElasticsearchVersion,
2222
enforceHttps: true,
23+
tlsSecurityPolicy: TLSSecurityPolicy.TLS_1_2,
2324
ebs: {
2425
enabled: true,
2526
volumeType: EbsDeviceVolumeType.GP2,

0 commit comments

Comments
 (0)