-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aws-lambda-opensearch): created new construct #818
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are 2 comments requiring changes - one about the service role and one about the comment on Cognito Domain name.
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/README.md
Outdated
Show resolved
Hide resolved
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
||
/** | ||
* @summary Constructs a new instance of the LambdaToOpenSearch class. | ||
* @param {cdk.App} scope - represents the scope for all the resources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is just copied from other Constructs, but can you think of a reason this says cdk.App instead of Construct? The type below is clearly Construct...
Should we change this in every construct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should change this in every construct
@@ -120,3 +120,18 @@ export function setupCognitoForElasticSearch(scope: Construct, domainName: strin | |||
|
|||
return cognitoAuthorizedRole; | |||
} | |||
|
|||
export function setupOpenSearchCognito(scope: Construct, domainName: string): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why you didn't follow the same naming pattern as setupCognitoForElasticSearch?
It's fine if you have a reason, the ElasticSearch stuff will probably not live forever, but if we're changing the naming pattern we should have a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason, changed to setupCognitoForOpenSearch
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/lib/index.ts
Outdated
Show resolved
Hide resolved
var creds = new AWS.EnvironmentCredentials('AWS'); | ||
var endpoint = new AWS.Endpoint(openSearchDomain.endpoint); | ||
|
||
function postDocumentToOpenSearch(doc, context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you launched this and confirm that data ends up in OpenSearch when run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, data is shown in dashboards
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/test/lambda/index.js
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/core/lib/opensearch-helper.ts
Outdated
Show resolved
Hide resolved
|
||
const MAXIMUM_AZS_IN_OPENSEARCH_DOMAIN = 3; | ||
|
||
export interface BuildOpenSearchProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait a minute - if this exists, why were the props defined as any in index.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BuildOpenSearchProps interface are readonly, we want to to add securityGroupIds if a VPC is present
// ClusterStatus.red maximum is >= 1 for 1 minute, 1 consecutive time | ||
alarms.push(new cloudwatch.Alarm(scope, 'StatusRedAlarm', { | ||
metric: new cloudwatch.Metric({ | ||
namespace: 'AWS/ES', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why still ES instead of OS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenSearch kept ES prefix instead of creating new OS
source/patterns/@aws-solutions-constructs/core/lib/opensearch-helper.ts
Outdated
Show resolved
Hide resolved
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change requested
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/lib/index.ts
Outdated
Show resolved
Hide resolved
source/patterns/@aws-solutions-constructs/core/lib/vpc-helper.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple comments, one question
handler: 'index.handler' | ||
}; | ||
|
||
const openSearchDomain = 'solutions-constructs-domain'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we don't specify a cognito domain like we do in the Elasticsearch version of this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the integ.no-arguments.ts
for aws-lambda-opensearch
, I used only the required arguments to deploy the stack. Specifying both OpenSearch and Cognito domain separately is handled in integ.domain-arguments.ts
.
return new LambdaToOpenSearch(stack, 'test-lambda-opensearch-stack', props); | ||
} | ||
|
||
function getDefaultTestLambdaProps(): lambda.FunctionProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to change this, but it could have been a constant to reduce complexity a little (most compile languages would probably make this optimization at compile time):
const defaultTestLambdaProps: lambda.FunctionProps = {
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using this approach, I get an Asset resource already exists in another stack:
Asset is already associated with another stack 'Default'. Create a new Code instance for every stack.
Using a function will create a unique reference id for the Code/Asset resource in each CloudFormation stack:
When the AWS CDK deploys an app that references assets (either directly by the app code or through a library), the AWS CDK CLI first prepares and publishes the assets to an Amazon S3 bucket or Amazon ECR repository, which was created during bootstrapping. Only then are the resources defined in the stack deployed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - thanks, I learned something there!
source/patterns/@aws-solutions-constructs/aws-lambda-opensearch/test/lambda-opensearch.test.ts
Outdated
Show resolved
Hide resolved
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with 1 comment
return new LambdaToOpenSearch(stack, 'test-lambda-opensearch-stack', props); | ||
} | ||
|
||
function getDefaultTestLambdaProps(): lambda.FunctionProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - thanks, I learned something there!
Issue #817 , if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
fixes #817