deployment: Add option to disable Elasticsearch in Cloudformation

pull/780/head
cruizba 2023-03-13 17:17:41 +01:00
parent 8764b7a23b
commit 0694281504
1 changed files with 86 additions and 13 deletions

View File

@ -86,32 +86,42 @@ Parameters:
Type: Number Type: Number
Default: 1 Default: 1
# Enable Elasticsearch and Kibana
ElasticsearchEnabled:
Description: "Choose if you want OpenVidu to use Elasticsearch."
Type: String
AllowedValues:
- true
- false
Default: true
# Elasticsearch configuration # Elasticsearch configuration
ElasticsearchUser: ElasticsearchUser:
Description: "Username for Elasticsearch and Kibana" Description: "Username for Elasticsearch and Kibana. ('ElasticSearch Enabled' must be true)"
Type: String Type: String
AllowedPattern: ^((?!")(?! ).)+$ AllowedPattern: ^((?!")(?! ).)+$
ConstraintDescription: Elasticsearch user is mandatory (no whitespaces or quotations allowed) ConstraintDescription: Elasticsearch user is mandatory (no whitespaces or quotations allowed)
Default: elasticadmin Default: elasticadmin
ElasticsearchPassword: ElasticsearchPassword:
Description: "Password for Elasticsearch and Kibana" Description: "Password for Elasticsearch and Kibana ('ElasticSearch Enabled' must be true)"
Type: String Type: String
AllowedPattern: ^((?!")(?! ).)+$ AllowedPattern: ^((?!")(?! ).)+$
NoEcho: true NoEcho: true
ConstraintDescription: Elasticsearch password is mandatory (no whitespaces or quotations allowed) ConstraintDescription: Elasticsearch password is mandatory (no whitespaces or quotations allowed)
MinLength: 7
# Elasticsearch configuration # Elasticsearch configuration
ElasticsearchUrl: ElasticsearchUrl:
Description: "If you have an external Elasticsearch service running, put here the url to the service. If empty, an Elasticsearch service will be deployed next to OpenVidu." Description: "If you have an external Elasticsearch service running, put here the url to the service. If empty, an Elasticsearch service will be deployed next to OpenVidu. ('ElasticSearch Enabled' must be true)"
Type: String Type: String
AllowedPattern: (^(http|https):\/\/.*:[1-9]{1,5}+.*$|^$) AllowedPattern: (^(https?:\/\/)?([^:\/]+)(:([0-9]+))?(\/.*)?$)
ConstraintDescription: "It is very important to specify the Elasticsearch URL with the port used by this service. For example: https://es-example:443" ConstraintDescription: "It is very important to specify the Elasticsearch URL with the port used by this service. For example: https://es-example:443"
KibanaUrl: KibanaUrl:
Description: "If you have an external Kibana service running, put here the url to the service. If empty, a Kibana service will be deployed next to OpenVidu." Description: "If you have an external Kibana service running, put here the url to the service. If empty, a Kibana service will be deployed next to OpenVidu. ('ElasticSearch Enabled' must be true)"
Type: String Type: String
AllowedPattern: (^(http|https):\/\/.*:[1-9]{1,5}+.*$|^$) AllowedPattern: (^(https?:\/\/)?([^:\/]+)(:([0-9]+))?(\/.*)?$)
ConstraintDescription: "It is very important to specify the url with port used by this service. For example: https://kibana-example:443" ConstraintDescription: "It is very important to specify the url with port used by this service. For example: https://kibana-example:443"
# EC2 Instance configuration # EC2 Instance configuration
@ -267,6 +277,7 @@ Metadata:
- Label: - Label:
default: Elasticsearch and Kibana configuration default: Elasticsearch and Kibana configuration
Parameters: Parameters:
- ElasticsearchEnabled
- ElasticsearchUrl - ElasticsearchUrl
- KibanaUrl - KibanaUrl
- ElasticsearchUser - ElasticsearchUser
@ -316,6 +327,8 @@ Metadata:
OpenViduSecret: OpenViduSecret:
default: "Openvidu Secret" default: "Openvidu Secret"
# Kibana configuration # Kibana configuration
ElasticsearchEnabled:
default: "Enable Elasticsearch and Kibana"
ElasticsearchUrl: ElasticsearchUrl:
default: "Elasticsearch URL" default: "Elasticsearch URL"
KibanaUrl: KibanaUrl:
@ -352,6 +365,7 @@ Conditions:
Rules: Rules:
# Check recording
RecordingValidation: RecordingValidation:
RuleCondition: RuleCondition:
Fn::Or: [ !Equals [!Ref Recording, 'disabled' ], !Equals [!Ref Recording, 'local' ] ] Fn::Or: [ !Equals [!Ref Recording, 'disabled' ], !Equals [!Ref Recording, 'local' ] ]
@ -359,6 +373,61 @@ Rules:
- AssertDescription: If recording Storage is 'disabled' or 'local', you don't need to specify a S3 bucket. - AssertDescription: If recording Storage is 'disabled' or 'local', you don't need to specify a S3 bucket.
Assert: Assert:
Fn::Equals: [ !Ref S3RecordingsBucketName, "" ] Fn::Equals: [ !Ref S3RecordingsBucketName, "" ]
# Check when Elasticsearch is enabled that all the parameters are present
ElasticsearchValidation:
RuleCondition:
Fn::Equals: [ !Ref ElasticsearchEnabled, 'true' ]
Assertions:
- AssertDescription: If Elasticsearch is enabled, you need to specify a Elasticsearch username.
Assert:
Fn::Not: [ !Equals [!Ref ElasticsearchUser, ''] ]
- AssertDescription: If Elasticsearch is enabled, you need to specify a Elasticsearch password.
Assert:
Fn::Not: [ !Equals [!Ref ElasticsearchPassword, ''] ]
# Check when Elasticsearch is disabled that any parameter of elasticsearch is not present
ElasticsearchDisabledValidation:
RuleCondition:
Fn::Equals: [ !Ref ElasticsearchEnabled, 'false' ]
Assertions:
- AssertDescription: If Elasticsearch is disabled, you don't need to specify a Elasticsearch URL.
Assert:
Fn::Equals: [ !Ref ElasticsearchUrl, "" ]
- AssertDescription: If Elasticsearch is disabled, you don't need to specify a Kibana URL.
Assert:
Fn::Equals: [ !Ref KibanaUrl, "" ]
- AssertDescription: If Elasticsearch is disabled, you don't need to specify a Elasticsearch username.
Assert:
Fn::Equals: [ !Ref ElasticsearchUser, "" ]
- AssertDescription: If Elasticsearch is disabled, you don't need to specify a Elasticsearch password.
Assert:
Fn::Equals: [ !Ref ElasticsearchPassword, "" ]
# Check Elastic IP is defined if letsencrypt or owncert is selected
ElasticIPValidation:
RuleCondition:
Fn::Or: [ !Equals [!Ref WhichCert, 'letsencrypt' ], !Equals [!Ref WhichCert, 'owncert' ] ]
Assertions:
- AssertDescription: If you want to use Let's Encrypt or your own certificate, you need to specify a Elastic IP.
Assert:
Fn::Not: [ !Equals [!Ref PublicElasticIP, ''] ]
# Check Let's Encrypt email is defined if letsencrypt is selected
LetsEncryptEmailValidation:
RuleCondition:
Fn::Equals: [ !Ref WhichCert, 'letsencrypt' ]
Assertions:
- AssertDescription: If you want to use Let's Encrypt, you need to specify a Let's Encrypt email.
Assert:
Fn::Not: [ !Equals [!Ref LetsEncryptEmail, ''] ]
# Check OwnCertCRT and OwnCertKEY are defined if owncert is selected
OwnCertValidation:
RuleCondition:
Fn::Equals: [ !Ref WhichCert, 'owncert' ]
Assertions:
- AssertDescription: If you want to use your own certificate, you need to specify a CRT file.
Assert:
Fn::Not: [ !Equals [!Ref OwnCertCRT, ''] ]
- AssertDescription: If you want to use your own certificate, you need to specify a KEY file.
Assert:
Fn::Not: [ !Equals [!Ref OwnCertKEY, ''] ]
Resources: Resources:
@ -520,6 +589,7 @@ Resources:
sed -i "s/LETSENCRYPT_EMAIL=user@example.com/LETSENCRYPT_EMAIL=${LetsEncryptEmail}/" $WORKINGDIR/.env sed -i "s/LETSENCRYPT_EMAIL=user@example.com/LETSENCRYPT_EMAIL=${LetsEncryptEmail}/" $WORKINGDIR/.env
# Replace Elastic Search Conf # Replace Elastic Search Conf
if [[ "${ElasticsearchEnabled}" == "true" ]]; then
if [[ ! -z "${ElasticsearchUrl}" ]]; then if [[ ! -z "${ElasticsearchUrl}" ]]; then
sed -i "s,#OPENVIDU_PRO_ELASTICSEARCH_HOST=,OPENVIDU_PRO_ELASTICSEARCH_HOST=${ElasticsearchUrl}," $WORKINGDIR/.env sed -i "s,#OPENVIDU_PRO_ELASTICSEARCH_HOST=,OPENVIDU_PRO_ELASTICSEARCH_HOST=${ElasticsearchUrl}," $WORKINGDIR/.env
fi fi
@ -528,6 +598,9 @@ Resources:
fi fi
sed -i "s/ELASTICSEARCH_USERNAME=elasticadmin/ELASTICSEARCH_USERNAME=${ElasticsearchUser}/" $WORKINGDIR/.env sed -i "s/ELASTICSEARCH_USERNAME=elasticadmin/ELASTICSEARCH_USERNAME=${ElasticsearchUser}/" $WORKINGDIR/.env
sed -i "s/ELASTICSEARCH_PASSWORD=/ELASTICSEARCH_PASSWORD=${ElasticsearchPassword}/" $WORKINGDIR/.env sed -i "s/ELASTICSEARCH_PASSWORD=/ELASTICSEARCH_PASSWORD=${ElasticsearchPassword}/" $WORKINGDIR/.env
else
sed -i "s/OPENVIDU_PRO_ELASTICSEARCH=true/OPENVIDU_PRO_ELASTICSEARCH=false/" $WORKINGDIR/.env
fi
# Replace vars AWS # Replace vars AWS
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id) INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)