Skip to content

Commit

Permalink
removed kibana text in opensearch construct
Browse files Browse the repository at this point in the history
  • Loading branch information
mickychetta committed Oct 5, 2022
1 parent d926fd2 commit cdfc289
Show file tree
Hide file tree
Showing 28 changed files with 121 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ import * as cognito from 'aws-cdk-lib/aws-cognito';
import * as defaults from '@aws-solutions-constructs/core';
// Note: To ensure CDKv2 compatibility, keep the import statement for Construct separate
import { Construct } from 'constructs';
import { Role } from 'aws-cdk-lib/aws-iam';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import * as ec2 from 'aws-cdk-lib/aws-ec2';

/**
* @summary The properties for the CognitoToApiGatewayToLambda Construct
* @summary The properties for the LambdaToElasticSearchAndKibana Construct
*/
export interface LambdaToElasticSearchAndKibanaProps {
/**
Expand Down Expand Up @@ -99,10 +98,10 @@ export class LambdaToElasticSearchAndKibana extends Construct {
public readonly vpc?: ec2.IVpc;

/**
* @summary Constructs a new instance of the CognitoToApiGatewayToLambda class.
* @param {cdk.App} scope - represents the scope for all the resources.
* @summary Constructs a new instance of the LambdaToElasticSearchAndKibana class.
* @param {Constructs} scope - represents the scope for all the resources.
* @param {string} id - this is a a scope-unique id.
* @param {CognitoToApiGatewayToLambdaProps} props - user provided props for the construct
* @param {LambdaToElasticSearchAndKibanaProps} props - user provided props for the construct
* @since 0.8.0
* @access public
*/
Expand Down Expand Up @@ -146,7 +145,7 @@ export class LambdaToElasticSearchAndKibana extends Construct {
let cognitoAuthorizedRole: iam.Role;

[this.userPool, this.userPoolClient, this.identityPool, cognitoAuthorizedRole] =
this.setupCognito(this, props.cognitoDomainName ?? props.domainName);
defaults.buildCognitoForSearchService(this, props.cognitoDomainName ?? props.domainName);

const buildElasticSearchProps: any = {
userpool: this.userPool,
Expand Down Expand Up @@ -174,18 +173,4 @@ export class LambdaToElasticSearchAndKibana extends Construct {
this.cloudwatchAlarms = defaults.buildElasticSearchCWAlarms(this);
}
}

setupCognito(scope: Construct, domainName: string): [cognito.UserPool, cognito.UserPoolClient, cognito.CfnIdentityPool, iam.Role] {
const userPool = defaults.buildUserPool(scope);
const userPoolClient = defaults.buildUserPoolClient(scope, userPool);
const identityPool = defaults.buildIdentityPool(scope, userPool, userPoolClient);

const cognitoAuthorizedRole: Role = defaults.setupCognitoForElasticSearch(scope, domainName, {
userpool: userPool,
identitypool: identityPool,
userpoolclient: userPoolClient
});

return [userPool, userPoolClient, identityPool, cognitoAuthorizedRole];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@
"Properties": {
"Code": {
"S3Bucket": "cdk-hnb659fds-assets-12345678-test-region",
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"Properties": {
"Code": {
"S3Bucket": "cdk-hnb659fds-assets-12345678-test-region",
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "67a9971e29baab2bde3043bb70ce5b53318b95429a1ce9b189cf65223e8682db.zip"
"S3Key": "35bbbc7b04b21f225891f139adf234188f348ebad5f4bbc2c06edf8aa3784c97.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function postDocumentToES(doc, context) {
var body = '';
httpResp.on('data', function (chunk) {
body += chunk;
});
});
httpResp.on('end', function (chunk) {
console.log('All movie records added to ES.');
context.succeed();
Expand All @@ -47,10 +47,13 @@ function postDocumentToES(doc, context) {

exports.handler = (event, context) => {
console.log('Received event:', JSON.stringify(event, null, 2));
postDocumentToES("{ \"title\": \"Spirited Away\" }", context);
return {
      statusCode200,
      headers{ 'Content-Type''text/plain' },
      body`Hello from Project Vesper! You've hit ${event.path}\n`
    };
postDocumentToOpenSearch("{ \"title\": \"Moby Dick\" }", context);
postDocumentToOpenSearch("{ \"title\": \"A Tale of Two Cities\" }", context);
postDocumentToOpenSearch("{ \"title\": \"The Phantom of the Opera\" }", context);

return {
statusCode: 200,
headers: { 'Content-Type': 'text/plain' },
body: `Hello from AWS Solutions Constructs!\n`
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ lib/*.js
test/*.js
*.d.ts
coverage
test/lambda/index.js
test/lambda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dist
coverage
.nycrc
.LAST_PACKAGE
*.snk
*.snk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ dist
!.jsii

# Include .jsii
!.jsii
!.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class LambdaToOpenSearch extends Construct {

/**
* @summary Constructs a new instance of the LambdaToOpenSearch class.
* @param {cdk.App} scope - represents the scope for all the resources.
* @param {Construct} scope - represents the scope for all the resources.
* @param {string} id - this is a a scope-unique id.
* @param {LambdaToOpenSearchProps} props - user provided props for the construct
* @since 0.8.0
Expand Down Expand Up @@ -145,7 +145,7 @@ export class LambdaToOpenSearch extends Construct {
let cognitoAuthorizedRole: iam.Role;

[this.userPool, this.userPoolClient, this.identityPool, cognitoAuthorizedRole] =
defaults.setupOpenSearchCognito(this, props.cognitoDomainName ?? props.openSearchDomainName);
defaults.buildCognitoForSearchService(this, props.cognitoDomainName ?? props.openSearchDomainName);

const buildOpenSearchProps: any = {
userpool: this.userPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "466cbfc6653782bd2707dec5bc5c58005c75a8bff3660a58eefa57d667120240.zip"
"S3Key": "abbc4eca9e7ddabc31da3ce83159e6eee8e72e2c358ab8af0711044514c41290.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -374,7 +374,7 @@
}
}
},
"testlambdaopensearchCognitoKibanaConfigureRole9623271F": {
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand All @@ -391,7 +391,7 @@
}
}
},
"testlambdaopensearchCognitoKibanaConfigureRolePolicyE9D9C211": {
"testlambdaopensearchCognitoDashboardConfigureRolePolicyC9C6A6A2": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -466,18 +466,18 @@
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"testlambdaopensearchCognitoKibanaConfigureRole9623271F",
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A",
"Arn"
]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "testlambdaopensearchCognitoKibanaConfigureRolePolicyE9D9C211",
"PolicyName": "testlambdaopensearchCognitoDashboardConfigureRolePolicyC9C6A6A2",
"Roles": [
{
"Ref": "testlambdaopensearchCognitoKibanaConfigureRole9623271F"
"Ref": "testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A"
}
]
}
Expand Down Expand Up @@ -542,7 +542,7 @@
},
"RoleArn": {
"Fn::GetAtt": [
"testlambdaopensearchCognitoKibanaConfigureRole9623271F",
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A",
"Arn"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "466cbfc6653782bd2707dec5bc5c58005c75a8bff3660a58eefa57d667120240.zip"
"S3Key": "abbc4eca9e7ddabc31da3ce83159e6eee8e72e2c358ab8af0711044514c41290.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -370,7 +370,7 @@
}
}
},
"testlambdaopensearchCognitoKibanaConfigureRole9623271F": {
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand All @@ -387,7 +387,7 @@
}
}
},
"testlambdaopensearchCognitoKibanaConfigureRolePolicyE9D9C211": {
"testlambdaopensearchCognitoDashboardConfigureRolePolicyC9C6A6A2": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -462,18 +462,18 @@
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"testlambdaopensearchCognitoKibanaConfigureRole9623271F",
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A",
"Arn"
]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "testlambdaopensearchCognitoKibanaConfigureRolePolicyE9D9C211",
"PolicyName": "testlambdaopensearchCognitoDashboardConfigureRolePolicyC9C6A6A2",
"Roles": [
{
"Ref": "testlambdaopensearchCognitoKibanaConfigureRole9623271F"
"Ref": "testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A"
}
]
}
Expand Down Expand Up @@ -535,7 +535,7 @@
},
"RoleArn": {
"Fn::GetAtt": [
"testlambdaopensearchCognitoKibanaConfigureRole9623271F",
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A",
"Arn"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "466cbfc6653782bd2707dec5bc5c58005c75a8bff3660a58eefa57d667120240.zip"
"S3Key": "abbc4eca9e7ddabc31da3ce83159e6eee8e72e2c358ab8af0711044514c41290.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -313,7 +313,7 @@
}
}
},
"testlambdaopensearchCognitoKibanaConfigureRole9623271F": {
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand All @@ -330,7 +330,7 @@
}
}
},
"testlambdaopensearchCognitoKibanaConfigureRolePolicyE9D9C211": {
"testlambdaopensearchCognitoDashboardConfigureRolePolicyC9C6A6A2": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand Down Expand Up @@ -405,18 +405,18 @@
"Effect": "Allow",
"Resource": {
"Fn::GetAtt": [
"testlambdaopensearchCognitoKibanaConfigureRole9623271F",
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A",
"Arn"
]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "testlambdaopensearchCognitoKibanaConfigureRolePolicyE9D9C211",
"PolicyName": "testlambdaopensearchCognitoDashboardConfigureRolePolicyC9C6A6A2",
"Roles": [
{
"Ref": "testlambdaopensearchCognitoKibanaConfigureRole9623271F"
"Ref": "testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A"
}
]
}
Expand Down Expand Up @@ -481,7 +481,7 @@
},
"RoleArn": {
"Fn::GetAtt": [
"testlambdaopensearchCognitoKibanaConfigureRole9623271F",
"testlambdaopensearchCognitoDashboardConfigureRole1F2B7B7A",
"Arn"
]
},
Expand Down
Loading

0 comments on commit cdfc289

Please sign in to comment.