Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public makeElasticsearchDataSource() {
const logicalName = ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID
return new AppSync.DataSource({
ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
Name: logicalName,
Type: 'AMAZON_ELASTICSEARCH',
ServiceRoleArn: Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchAccessIAMRoleLogicalID, 'Arn'),
ElasticsearchConfig: {
AwsRegion: Fn.Select(3, Fn.Split(':', Fn.GetAtt(logicalName, 'DomainArn'))),
Endpoint:
Fn.Join('', [
'https://',
Fn.GetAtt(logicalName, 'DomainEndpoint')
])
}
}).dependsOn(ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID)
}
'functions',
Fn.Join('.', [ResourceConstants.RESOURCES.ElasticsearchStreamingLambdaFunctionLogicalID, 'zip']),
]),
},
FunctionName: this.joinWithEnv('-', [
Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchStreamingFunctionName),
Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
]),
Handler: Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchStreamingLambdaHandlerName),
Role: Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchStreamingLambdaIAMRoleLogicalID, 'Arn'),
Runtime: Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchStreamingLambdaRuntime),
Layers: [Fn.FindInMap('LayerResourceMapping', Fn.Ref('AWS::Region'), 'layerRegion')],
Environment: {
Variables: {
ES_ENDPOINT: Fn.Join('', ['https://', Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID, 'DomainEndpoint')]),
ES_REGION: Fn.Select(3, Fn.Split(':', Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID, 'DomainArn'))),
DEBUG: Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchDebugStreamingLambda),
},
},
}).dependsOn([
ResourceConstants.RESOURCES.ElasticsearchStreamingLambdaIAMRoleLogicalID,
ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID,
]);
}
])
},
FunctionName: this.joinWithEnv("-", [
Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchStreamingFunctionName),
Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
]),
Handler: Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchStreamingLambdaHandlerName),
Role: Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchStreamingLambdaIAMRoleLogicalID, 'Arn'),
Runtime: Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchStreamingLambdaRuntime),
Environment: {
Variables: {
ES_ENDPOINT: Fn.Join('', [
'https://',
Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID, 'DomainEndpoint')
]),
ES_REGION: Fn.Select(3, Fn.Split(':', Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID, 'DomainArn'))),
DEBUG: Fn.Ref(ResourceConstants.PARAMETERS.ElasticsearchDebugStreamingLambda)
}
}
}).dependsOn([
ResourceConstants.RESOURCES.ElasticsearchStreamingLambdaIAMRoleLogicalID,
ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID
])
}
public makeElasticsearchDataSource() {
const logicalName = ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID;
return new AppSync.DataSource({
ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
Name: logicalName,
Type: 'AMAZON_ELASTICSEARCH',
ServiceRoleArn: Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchAccessIAMRoleLogicalID, 'Arn'),
ElasticsearchConfig: {
AwsRegion: Fn.Select(3, Fn.Split(':', Fn.GetAtt(logicalName, 'DomainArn'))),
Endpoint: Fn.Join('', ['https://', Fn.GetAtt(logicalName, 'DomainEndpoint')]),
},
}).dependsOn(ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID);
}