File tree 5 files changed +70
-10
lines changed
packages/serverless-cms-aws/src 5 files changed +70
-10
lines changed Original file line number Diff line number Diff line change @@ -10,30 +10,30 @@ export const checkEsServiceRole = {
10
10
name : "hook-before-deploy-es-service-role" ,
11
11
async hook ( params : Record < string , any > , context : CliContext ) {
12
12
const spinner = ora ( ) ;
13
- spinner . start ( `Checking Elastic Search service role...` ) ;
13
+ spinner . start ( `Checking Amazon Elasticsearch service role...` ) ;
14
14
const iam = new IAM ( ) ;
15
15
try {
16
16
await iam . getRole ( { RoleName : "AWSServiceRoleForAmazonElasticsearchService" } ) ;
17
17
18
18
spinner . stopAndPersist ( {
19
19
symbol : green ( "✔" ) ,
20
- text : `Found Elastic Search service role!`
20
+ text : `Found Amazon Elasticsearch service role!`
21
21
} ) ;
22
- context . success ( `Found Elastic Search service role!` ) ;
22
+ context . success ( `Found Amazon Elasticsearch service role!` ) ;
23
23
} catch ( err ) {
24
24
// We've seen cases where the `iam.getRole` call fails because of an issue
25
25
// other than not being able to retrieve the service role. Let's print
26
26
// additional info if that's the case. Will make debugging a bit easier.
27
27
if ( err . code !== NO_SUCH_ENTITY_IAM_ERROR ) {
28
28
spinner . fail (
29
- "Tried retrieving Elastic Search service role but failed with the following error: " +
29
+ "Tried retrieving Amazon Elasticsearch service role but failed with the following error: " +
30
30
err . message
31
31
) ;
32
32
context . debug ( err ) ;
33
33
process . exit ( 1 ) ;
34
34
}
35
35
36
- spinner . text = "Creating Elastic Search service role..." ;
36
+ spinner . text = "Creating Amazon Elasticsearch service role..." ;
37
37
38
38
try {
39
39
await iam . createServiceLinkedRole ( { AWSServiceName : "es.amazonaws.com" } ) ;
Original file line number Diff line number Diff line change
1
+ import { IAM } from "@webiny/aws-sdk/client-iam" ;
2
+ import ora from "ora" ;
3
+ import { green } from "chalk" ;
4
+ import { CliContext } from "@webiny/cli/types" ;
5
+
6
+ const NO_SUCH_ENTITY_IAM_ERROR = "NoSuchEntity" ;
7
+
8
+ export const checkOsServiceRole = {
9
+ type : "hook-before-deploy" ,
10
+ name : "hook-before-deploy-es-service-role" ,
11
+ async hook ( params : Record < string , any > , context : CliContext ) {
12
+ const spinner = ora ( ) ;
13
+ spinner . start ( `Checking Amazon OpenSearch service role...` ) ;
14
+ const iam = new IAM ( ) ;
15
+ try {
16
+ await iam . getRole ( { RoleName : "AWSServiceRoleForAmazonOpenSearchService" } ) ;
17
+
18
+ spinner . stopAndPersist ( {
19
+ symbol : green ( "✔" ) ,
20
+ text : `Found Amazon OpenSearch service role!`
21
+ } ) ;
22
+ context . success ( `Found Amazon OpenSearch service role!` ) ;
23
+ } catch ( err ) {
24
+ // We've seen cases where the `iam.getRole` call fails because of an issue
25
+ // other than not being able to retrieve the service role. Let's print
26
+ // additional info if that's the case. Will make debugging a bit easier.
27
+ if ( err . code !== NO_SUCH_ENTITY_IAM_ERROR ) {
28
+ spinner . fail (
29
+ "Tried retrieving Amazon OpenSearch service role but failed with the following error: " +
30
+ err . message
31
+ ) ;
32
+ context . debug ( err ) ;
33
+ process . exit ( 1 ) ;
34
+ }
35
+
36
+ spinner . text = "Creating Amazon OpenSearch service role..." ;
37
+
38
+ try {
39
+ await iam . createServiceLinkedRole ( { AWSServiceName : "es.amazonaws.com" } ) ;
40
+
41
+ spinner . stop ( ) ;
42
+ } catch ( err ) {
43
+ spinner . fail ( err . message ) ;
44
+ context . debug ( err ) ;
45
+ process . exit ( 1 ) ;
46
+ }
47
+ }
48
+ }
49
+ } ;
Original file line number Diff line number Diff line change 1
1
export * from "./generateDdbToEsHandler" ;
2
2
export * from "./checkEsServiceRole" ;
3
+ export * from "./checkOsServiceRole" ;
Original file line number Diff line number Diff line change 1
1
import { createCorePulumiApp , CreateCorePulumiAppParams } from "@webiny/pulumi-aws" ;
2
2
import { PluginCollection } from "@webiny/plugins/types" ;
3
- import { generateDdbToEsHandler , checkEsServiceRole } from "./core/plugins" ;
3
+ import { generateDdbToEsHandler , checkEsServiceRole , checkOsServiceRole } from "./core/plugins" ;
4
4
5
5
export { CoreOutput , configureAdminCognitoFederation } from "@webiny/pulumi-aws" ;
6
6
@@ -11,7 +11,12 @@ export interface CreateCoreAppParams extends CreateCorePulumiAppParams {
11
11
export function createCoreApp ( projectAppParams : CreateCoreAppParams = { } ) {
12
12
const builtInPlugins = [ ] ;
13
13
if ( projectAppParams . elasticSearch || projectAppParams . openSearch ) {
14
- builtInPlugins . push ( generateDdbToEsHandler , checkEsServiceRole ) ;
14
+ builtInPlugins . push ( generateDdbToEsHandler ) ;
15
+ if ( projectAppParams . elasticSearch ) {
16
+ builtInPlugins . push ( checkEsServiceRole ) ;
17
+ } else {
18
+ builtInPlugins . push ( checkOsServiceRole ) ;
19
+ }
15
20
}
16
21
17
22
const customPlugins = projectAppParams . plugins ? [ ...projectAppParams . plugins ] : [ ] ;
Original file line number Diff line number Diff line change 1
1
import { createCorePulumiApp , CreateCorePulumiAppParams } from "@webiny/pulumi-aws/enterprise" ;
2
2
import { PluginCollection } from "@webiny/plugins/types" ;
3
- import { generateDdbToEsHandler , checkEsServiceRole } from "~/core/plugins" ;
3
+ import { generateDdbToEsHandler , checkEsServiceRole , checkOsServiceRole } from "~/core/plugins" ;
4
4
5
- export { CoreOutput } from "@webiny/pulumi-aws" ;
5
+ export { CoreOutput , configureAdminCognitoFederation } from "@webiny/pulumi-aws" ;
6
6
7
7
export interface CreateCoreAppParams extends CreateCorePulumiAppParams {
8
8
plugins ?: PluginCollection ;
@@ -11,7 +11,12 @@ export interface CreateCoreAppParams extends CreateCorePulumiAppParams {
11
11
export function createCoreApp ( projectAppParams : CreateCoreAppParams = { } ) {
12
12
const builtInPlugins = [ ] ;
13
13
if ( projectAppParams . elasticSearch || projectAppParams . openSearch ) {
14
- builtInPlugins . push ( generateDdbToEsHandler , checkEsServiceRole ) ;
14
+ builtInPlugins . push ( generateDdbToEsHandler ) ;
15
+ if ( projectAppParams . elasticSearch ) {
16
+ builtInPlugins . push ( checkEsServiceRole ) ;
17
+ } else {
18
+ builtInPlugins . push ( checkOsServiceRole ) ;
19
+ }
15
20
}
16
21
17
22
const customPlugins = projectAppParams . plugins ? [ ...projectAppParams . plugins ] : [ ] ;
You can’t perform that action at this time.
0 commit comments