From ff0037a0c28538c18ea58ea54518d164b3655dd5 Mon Sep 17 00:00:00 2001 From: maz Date: Wed, 4 Sep 2024 21:02:58 +0900 Subject: [PATCH] dataSource property is not required --- packages/@aws-cdk/aws-location-alpha/lib/place-index.ts | 6 ++---- .../@aws-cdk/aws-location-alpha/test/integ.place-index.ts | 6 ++++-- .../@aws-cdk/aws-location-alpha/test/place-index.test.ts | 8 +++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts b/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts index 026d8c5268a68..a7d1b3008cbaf 100644 --- a/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts +++ b/packages/@aws-cdk/aws-location-alpha/lib/place-index.ts @@ -39,10 +39,8 @@ export interface PlaceIndexProps { /** * Data source for the place index - * - * @default DataSource.ESRI */ - readonly dataSource?: DataSource; + readonly dataSource: DataSource; /** * Intend use for the results of an operation @@ -159,7 +157,7 @@ export class PlaceIndex extends PlaceIndexBase { */ public readonly placeIndexUpdateTime: string; - constructor(scope: Construct, id: string, props: PlaceIndexProps = {}) { + constructor(scope: Construct, id: string, props: PlaceIndexProps) { if (props.description && !Token.isUnresolved(props.description) && props.description.length > 1000) { throw new Error(`\`description\` must be between 0 and 1000 characters. Received: ${props.description.length} characters`); } diff --git a/packages/@aws-cdk/aws-location-alpha/test/integ.place-index.ts b/packages/@aws-cdk/aws-location-alpha/test/integ.place-index.ts index ec7b4274795fd..19e39e36a9db6 100644 --- a/packages/@aws-cdk/aws-location-alpha/test/integ.place-index.ts +++ b/packages/@aws-cdk/aws-location-alpha/test/integ.place-index.ts @@ -1,13 +1,15 @@ import { App, Stack } from 'aws-cdk-lib'; import * as integ from '@aws-cdk/integ-tests-alpha'; import { Construct } from 'constructs'; -import { PlaceIndex } from '../lib'; +import { DataSource, PlaceIndex } from '../lib'; class TestStack extends Stack { constructor(scope: Construct, id: string) { super(scope, id); - new PlaceIndex(this, 'PlaceIndex'); + new PlaceIndex(this, 'PlaceIndex', { + dataSource: DataSource.ESRI, + }); } } diff --git a/packages/@aws-cdk/aws-location-alpha/test/place-index.test.ts b/packages/@aws-cdk/aws-location-alpha/test/place-index.test.ts index 610de8421a424..f01b11d7d479a 100644 --- a/packages/@aws-cdk/aws-location-alpha/test/place-index.test.ts +++ b/packages/@aws-cdk/aws-location-alpha/test/place-index.test.ts @@ -10,7 +10,9 @@ beforeEach(() => { }); test('create a place index', () => { - new PlaceIndex(stack, 'PlaceIndex'); + new PlaceIndex(stack, 'PlaceIndex', { + dataSource: DataSource.ESRI, + }); Template.fromStack(stack).hasResourceProperties('AWS::Location::PlaceIndex', { DataSource: 'Esri', @@ -21,6 +23,7 @@ test('create a place index', () => { test('create a place index with description', () => { new PlaceIndex(stack, 'PlaceIndex', { description: 'my-description', + dataSource: DataSource.ESRI, }); Template.fromStack(stack).hasResourceProperties('AWS::Location::PlaceIndex', { @@ -33,6 +36,7 @@ test('create a place index with description', () => { test('creates a place index with empty description', () => { new PlaceIndex(stack, 'PlaceIndex', { description: '', + dataSource: DataSource.ESRI, }); Template.fromStack(stack).hasResourceProperties('AWS::Location::PlaceIndex', { @@ -43,12 +47,14 @@ test('creates a place index with empty description', () => { test('throws with invalid description', () => { expect(() => new PlaceIndex(stack, 'PlaceIndex', { description: 'a'.repeat(1001), + dataSource: DataSource.ESRI, })).toThrow('`description` must be between 0 and 1000 characters. Received: 1001 characters'); }); test('throws with invalid name', () => { expect(() => new PlaceIndex(stack, 'PlaceIndex', { placeIndexName: 'inv@lid', + dataSource: DataSource.ESRI, })).toThrow(/Invalid place index name/); });