Package: aws-solutions-constructs.aws-lambda-opensearch
aws-lambda-opensearch module---All classes are under active development and subject to non-backward compatible changes or removal in any
future version. These are not subject to theSemantic Versioningmodel.
This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.Reference Documentation:https://docs.aws.amazon.com/solutions/latest/constructs/LanguagePackagePythonaws_solutions_constructs.aws_lambda_opensearchTypescript@aws-solutions-constructs/aws-lambda-opensearchJavasoftware.amazon.awsconstructs.services.lambdaopensearchOverviewThis AWS Solutions Construct implements an AWS Lambda function and Amazon OpenSearch Service with the least privileged permissions.Here is a minimal deployable pattern definition:Typescriptimport{Construct}from'constructs';import{Stack,StackProps,Aws}from'aws-cdk-lib';import{LambdaToOpenSearch}from'@aws-solutions-constructs/aws-lambda-opensearch';import*aslambdafrom"aws-cdk-lib/aws-lambda";constlambdaProps:lambda.FunctionProps={code:lambda.Code.fromAsset(`lambda`),runtime:lambda.Runtime.NODEJS_16_X,handler:'index.handler'};newLambdaToOpenSearch(this,'sample',{lambdaFunctionProps:lambdaProps,openSearchDomainName:'testdomain',//TODO:EnsuretheCognitodomainnameisgloballyuniquecognitoDomainName:'globallyuniquedomain'+Aws.ACCOUNT_ID});Pythonfromaws_solutions_constructs.aws_lambda_opensearchimportLambdaToOpenSearchfromaws_cdkimport(aws_lambdaas_lambda,Aws,Stack)fromconstructsimportConstructlambda_props=_lambda.FunctionProps(code=_lambda.Code.from_asset('lambda'),runtime=_lambda.Runtime.PYTHON_3_9,handler='index.handler')LambdaToOpenSearch(self,'sample',lambda_function_props=lambda_props,open_search_domain_name='testdomain',# TODO: Ensure the Cognito domain name is globally uniquecognito_domain_name='globallyuniquedomain'+Aws.ACCOUNT_ID)Javaimportsoftware.constructs.Construct;importsoftware.amazon.awscdk.Stack;importsoftware.amazon.awscdk.StackProps;importsoftware.amazon.awscdk.Aws;importsoftware.amazon.awscdk.services.lambda.*;importsoftware.amazon.awscdk.services.lambda.Runtime;importsoftware.amazon.awsconstructs.services.lambdaopensearch.*;newLambdaToOpenSearch(this,"sample",newLambdaToOpenSearchProps.Builder().lambdaFunctionProps(newFunctionProps.Builder().runtime(Runtime.NODEJS_16_X).code(Code.fromAsset("lambda")).handler("index.handler").build()).openSearchDomainName("testdomain")// TODO: Ensure the Cognito domain name is globally unique.cognitoDomainName("globallyuniquedomain"+Aws.ACCOUNT_ID).build());Pattern Construct PropsNameTypeDescriptionexistingLambdaObj?lambda.FunctionExisting instance of Lambda Function object, providing both this andlambdaFunctionPropswill cause an error.lambdaFunctionProps?lambda.FunctionPropsUser provided props to override the default props for the Lambda function.openSearchDomainProps?opensearchservice.CfnDomainPropsOptional user provided props to override the default props for the OpenSearch Service.openSearchDomainNamestringDomain name for the OpenSearch Service.cognitoDomainName?stringOptional Amazon Cognito domain name. If omitted the Amazon Cognito domain will default to the OpenSearch Service domain name.createCloudWatchAlarms?booleanWhether to create the recommended CloudWatch alarms.domainEndpointEnvironmentVariableName?stringOptional name for the OpenSearch domain endpoint environment variable set for the Lambda function. Default isDOMAIN_ENDPOINT.existingVpc?ec2.IVpcAn optional, existing VPC into which this pattern should be deployed. When deployed in a VPC, the Lambda function will use ENIs in the VPC to access network resources. If an existing VPC is provided, thedeployVpcproperty cannot betrue. This usesec2.IVpcto allow clients to supply VPCs that exist outside the stack using theec2.Vpc.fromLookup()method.vpcProps?ec2.VpcPropsOptional user provided properties to override the default properties for the new VPC.enableDnsHostnames,enableDnsSupport,natGatewaysandsubnetConfigurationare set by the pattern, so any values for those properties supplied here will be overridden. IfdeployVpcis nottruethen this property will be ignored.deployVpc?booleanWhether to create a new VPC based onvpcPropsinto which to deploy this pattern. Setting this to true will deploy the minimal, most private VPC to run the pattern:One isolated subnet in each Availability Zone used by the CDK programenableDnsHostnamesandenableDnsSupportwill both be set to trueIf this property istruethenexistingVpccannot be specified. Defaults tofalse.Pattern PropertiesNameTypeDescriptionlambdaFunctionlambda.FunctionReturns an instance oflambda.Functioncreated by the constructuserPoolcognito.UserPoolReturns an instance ofcognito.UserPoolcreated by the constructuserPoolClientcognito.UserPoolClientReturns an instance ofcognito.UserPoolClientcreated by the constructidentityPoolcognito.CfnIdentityPoolReturns an instance ofcognito.CfnIdentityPoolcreated by the constructopenSearchDomainopensearchservice.CfnDomainReturns an instance ofopensearch.CfnDomaincreated by the constructopenSearchRoleiam.RoleReturns an instance ofiam.Rolecreated by the construct foropensearch.CfnDomaincloudWatchAlarms?cloudwatch.Alarm[]Returns a list ofcloudwatch.Alarmcreated by the constructvpc?ec2.IVpcReturns an interface on the VPC used by the pattern (if any). This may be a VPC created by the pattern or the VPC supplied to the pattern constructor.Lambda FunctionThis pattern requires a lambda function that can post data into the OpenSearch. A sample function is providedhere.Default settingsOut of the box implementation of the Construct without any overrides will set the following defaults:AWS Lambda FunctionConfigure limited privilege access IAM role for Lambda functionEnable reusing connections with Keep-Alive for Node.js Lambda functionEnable X-Ray TracingSet Environment Variables(default) DOMAIN_ENDPOINTAWS_NODEJS_CONNECTION_REUSE_ENABLEDAmazon CognitoSet password policy for User PoolsEnforce the advanced security mode for User PoolsAmazon OpenSearch ServiceDeploy best practices CloudWatch Alarms for the OpenSearch Service domainSecure the OpenSearch Service dashboard access with Cognito User PoolsEnable server-side encryption for OpenSearch Service domain using AWS managed KMS KeyEnable node-to-node encryption for the OpenSearch Service domainConfigure the cluster for the OpenSearch Service domainArchitecture© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.