Skip to content

Commit 5bf0316

Browse files
authored
Add opensearch datasource (#465)
1 parent f562308 commit 5bf0316

File tree

3 files changed

+153
-1
lines changed

3 files changed

+153
-1
lines changed

__snapshots__/index.test.js.snap

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,125 @@ Object {
24482448
},
24492449
"Type": "AWS::IAM::Role",
24502450
},
2451+
"GraphQlDsOpenSearchSource2Role": Object {
2452+
"Properties": Object {
2453+
"AssumeRolePolicyDocument": Object {
2454+
"Statement": Array [
2455+
Object {
2456+
"Action": Array [
2457+
"sts:AssumeRole",
2458+
],
2459+
"Effect": "Allow",
2460+
"Principal": Object {
2461+
"Service": Array [
2462+
"appsync.amazonaws.com",
2463+
],
2464+
},
2465+
},
2466+
],
2467+
"Version": "2012-10-17",
2468+
},
2469+
"Policies": Array [
2470+
Object {
2471+
"PolicyDocument": Object {
2472+
"Statement": Array [
2473+
Object {
2474+
"Action": Array [
2475+
"es:ESHttpDelete",
2476+
"es:ESHttpGet",
2477+
"es:ESHttpHead",
2478+
"es:ESHttpPost",
2479+
"es:ESHttpPut",
2480+
"es:ESHttpPatch",
2481+
],
2482+
"Effect": "Allow",
2483+
"Resource": Array [
2484+
Object {
2485+
"Fn::Join": Array [
2486+
"/",
2487+
Array [
2488+
Object {
2489+
"Fn::GetAtt": Array [
2490+
Object {
2491+
"Ref": "OSDomain",
2492+
},
2493+
"Arn",
2494+
],
2495+
},
2496+
"*",
2497+
],
2498+
],
2499+
},
2500+
],
2501+
},
2502+
],
2503+
"Version": "2012-10-17",
2504+
},
2505+
"PolicyName": "GraphQlDsOpenSearchSource2Policy",
2506+
},
2507+
],
2508+
},
2509+
"Type": "AWS::IAM::Role",
2510+
},
2511+
"GraphQlDsOpenSearchSourceRole": Object {
2512+
"Properties": Object {
2513+
"AssumeRolePolicyDocument": Object {
2514+
"Statement": Array [
2515+
Object {
2516+
"Action": Array [
2517+
"sts:AssumeRole",
2518+
],
2519+
"Effect": "Allow",
2520+
"Principal": Object {
2521+
"Service": Array [
2522+
"appsync.amazonaws.com",
2523+
],
2524+
},
2525+
},
2526+
],
2527+
"Version": "2012-10-17",
2528+
},
2529+
"Policies": Array [
2530+
Object {
2531+
"PolicyDocument": Object {
2532+
"Statement": Array [
2533+
Object {
2534+
"Action": Array [
2535+
"es:ESHttpDelete",
2536+
"es:ESHttpGet",
2537+
"es:ESHttpHead",
2538+
"es:ESHttpPost",
2539+
"es:ESHttpPut",
2540+
"es:ESHttpPatch",
2541+
],
2542+
"Effect": "Allow",
2543+
"Resource": Array [
2544+
Object {
2545+
"Fn::Join": Array [
2546+
":",
2547+
Array [
2548+
"arn",
2549+
"aws",
2550+
"es",
2551+
"us-east-1",
2552+
Object {
2553+
"Ref": "AWS::AccountId",
2554+
},
2555+
"domain/search-my-os-domain-abcdefghijklmnop.us-east-1.es.amazonaws.com/*",
2556+
],
2557+
],
2558+
},
2559+
],
2560+
},
2561+
],
2562+
"Version": "2012-10-17",
2563+
},
2564+
"PolicyName": "GraphQlDsOpenSearchSourcePolicy",
2565+
},
2566+
],
2567+
},
2568+
"Type": "AWS::IAM::Role",
2569+
},
24512570
"GraphQlDsRelationalDbSourceRole": Object {
24522571
"Properties": Object {
24532572
"AssumeRolePolicyDocument": Object {

index.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,27 @@ describe('iamRoleStatements', () => {
949949
},
950950
},
951951
},
952+
{
953+
type: 'AMAZON_OPENSEARCH_SERVICE',
954+
name: 'OpenSearchSource',
955+
description: 'My OpenSearch Source',
956+
config: {
957+
region: 'us-east-1',
958+
endpoint:
959+
'https://search-my-os-domain-abcdefghijklmnop.us-east-1.es.amazonaws.com',
960+
},
961+
},
962+
{
963+
type: 'AMAZON_OPENSEARCH_SERVICE',
964+
name: 'OpenSearchSource2',
965+
description: 'other OS Source',
966+
config: {
967+
region: 'us-east-1',
968+
domain: {
969+
Ref: 'OSDomain',
970+
},
971+
},
972+
},
952973
],
953974
});
954975

@@ -1009,6 +1030,18 @@ describe('iamRoleStatements', () => {
10091030
'https://search-my-domain-abcdefghijklmnop.us-east-1.es.amazonaws.com',
10101031
},
10111032
},
1033+
{
1034+
type: 'AMAZON_OPENSEARCH',
1035+
name: 'OpenSearchSource',
1036+
description: 'My OpenSearch Source',
1037+
config: {
1038+
serviceRoleArn:
1039+
'arn:aws:iam::123456789012:role/service-role/myOsRole',
1040+
region: 'us-east-1',
1041+
endpoint:
1042+
'https://search-my-os-domain-abcdefghijklmnop.us-east-1.es.amazonaws.com',
1043+
},
1044+
},
10121045
{
10131046
type: 'HTTP',
10141047
name: 'HTTPSource',

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ class ServerlessAppsyncPlugin {
10121012
const result = rx.exec(ds.config.endpoint);
10131013
if (!result) {
10141014
throw new this.serverless.classes.Error(
1015-
`Invalid AWS ElasticSearch endpoint: '${ds.config.endpoint}`,
1015+
`Invalid AWS OpenSearch/ElasticSearch endpoint: '${ds.config.endpoint}`,
10161016
);
10171017
}
10181018
arn = {

0 commit comments

Comments
 (0)