Hi everyone!
I’m posting because it drive my crazy!
I’ve already found this topic : Can I access outputs from custom resources as variables in serverless.yml?
But, i couldn’t be able to have my endpoint on a single service project!
Code before 1000 words !
My ./resources/es-instance.yml :
Resources:
ElasticSearchLambdaServiceRole:
Type: AWS::IAM::Role
Properties:
RoleName: ElasticSearchLambdaServiceRole
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ElasticSearchGeoLambdaServiceRolePolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
# Public can query for information
- Effect: Allow
Principal: "*"
Action:
- "es:ESHttpHead"
- "es:ESHttpGet"
Resource: "arn:aws:es:${self:provider.region}:*:domain/${self:provider.environment.es_domain_name}/*"
# Lambda can take actions on the ES domain
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group~:/aws/lambda/*:*:*'
- Effect: "Allow"
Action:
- "es:*"
Resource:
- 'Fn::Join':
- ''
-
- 'arn:aws:es:'
- Ref: 'AWS::Region'
- ':'
- Ref: 'AWS::AccountId'
- ':domain/'
- "${self:provider.environment.es_domain_name}"
- '/*'
ElasticSearchInstance:
Type: AWS::Elasticsearch::Domain
Properties:
ElasticsearchVersion: 6.3
DomainName: "${self:provider.environment.es_domain_name}"
EBSOptions:
EBSEnabled: true
VolumeType: gp2
VolumeSize: 10
ElasticsearchClusterConfig:
InstanceType: t2.small.elasticsearch
InstanceCount: 1
DedicatedMasterEnabled: false
ZoneAwarenessEnabled: false
Outputs:
ElasticSearchInstance:
Value:
Ref: ElasticSearchInstance
ElasticSearchLambdaServiceRole:
Value:
Ref: ElasticSearchLambdaServiceRole
DomainEndpoint:
Value:
Fn::GetAtt: [ ElasticSearchInstance, DomainEndpoint ]
An extract from my serverless.yml
provider:
# ... some properties
environment:
# ... some properties
es_endpoint_url: ${file(./resources/es-instance.yml):Outputs.DomainEndpoint.Value}
On the terminal, I got :
Serverless: Resolved environment variable es_endpoint_url: {"Fn::GetAtt":["ElasticSearchInstance","DomainEndpoint"]}
So, why ? How can i access to the endpoint ?
I’ve tested a lot of things and nothing really worked
Do I missed something ?
Note : I don’t want to use dynamodb-geo so i’m searching to use ES for geoqueries
Thx a lot for the framework, i made a lot a great projects, hope someone will help me to figure it out