deployment-openvidu-pro: Easier configuration for s3 recordings

pull/550/head
cruizba 2020-10-07 21:08:14 +02:00
parent 98a35ab6ec
commit 6ea52fe061
2 changed files with 39 additions and 29 deletions

View File

@ -42,16 +42,20 @@ Parameters:
Description: "If certificate type is 'letsencrypt', this email will be used for Let's Encrypt notifications"
Type: String
RecordingStorage:
Description: "If 's3', recordings will be stored in a S3 bucket"
Recording:
Description: |
If 'disabled', recordings will not be active.
If 'local' recordings will be saved in EC2 instance locally.
If 's3', recordings will be stored in a S3 bucket"
Type: String
AllowedValues:
- disabled
- local
- s3
Default: local
S3RecordingsBucketName:
Description: "If RecordingStorage is 's3', this will be the name of s3 bucket to store recordings"
Description: "S3 Bucket Name"
Type: String
# OpenVidu Configuration
@ -224,7 +228,10 @@ Metadata:
- OpenViduLicense
- OpenViduSecret
- MediaNodesStartNumber
- RecordingStorage
- Label:
default: OpenVidu Recording Configuration
Parameters:
- Recording
- S3RecordingsBucketName
- Label:
default: Elasticsearch and Kibana configuration
@ -261,8 +268,8 @@ Metadata:
default: "URL to the key file (owncert)"
LetsEncryptEmail:
default: "Email for Let's Encrypt (letsencrypt)"
RecordingStorage:
default: "Recording storage"
Recording:
default: "OpenVidu Recording"
S3RecordingsBucketName:
default: "S3 Bucket where recordings will be stored"
# OpenVidu configuration
@ -294,20 +301,22 @@ Metadata:
default: "Deploy OpenVidu Call application"
Conditions:
WhichCertPresent: !Not [ !Equals [!Ref WhichCert, ""] ]
PublicElasticIPPresent: !Not [ !Equals [!Ref PublicElasticIP, ""] ]
RecordingStorageIsS3: !Equals [!Ref RecordingStorage, "s3" ]
S3RecordingsBucketNamePresent: !Not [ !Equals [!Ref S3RecordingsBucketName, ""] ]
CreateS3Bucket: !And [ !Equals [!Ref RecordingStorage, "s3" ], !Equals [!Ref S3RecordingsBucketName, ""] ]
WhichCertPresent: !Not [ !Equals [!Ref WhichCert, ''] ]
PublicElasticIPPresent: !Not [ !Equals [!Ref PublicElasticIP, ''] ]
RecordingStorageIsS3: !Equals [ !Ref Recording, 's3' ]
CreateS3Bucket: !And
- !Equals [!Ref Recording, 's3' ]
- !Equals [!Ref S3RecordingsBucketName, '']
Rules:
ValidateParametersS3Local:
RecordingValidation:
RuleCondition:
Fn::Equals: [!Ref RecordingStorage, "local" ]
Fn::Equals: [!Ref Recording, 'disabled' ]
Assertions:
- AssertDescription: If Recording Storage is 'local', you don't need to define an S3 bucket
- AssertDescription: If recording Storage is 'disabled', you don't need to specify a S3 bucket.
Assert:
Fn::Equals: [!Ref S3RecordingsBucketName, ""]
Fn::Equals: [ !Ref S3RecordingsBucketName, "" ]
Resources:
@ -353,9 +362,9 @@ Resources:
Resource:
- Fn::If:
# Get bucket name depending if the user defines a bucket name or not
- S3RecordingsBucketNamePresent
- !Join [ "", [ 'arn:aws:s3:::', !Ref S3RecordingsBucketName, '/*'] ]
- CreateS3Bucket
- !Join [ "", [ 'arn:aws:s3:::', !Ref AWS::StackName, '-recordings', '/*'] ]
- !Join [ "", [ 'arn:aws:s3:::', !Ref S3RecordingsBucketName, '/*'] ]
- Ref: AWS::NoValue
- Fn::If:
# Only apply this policy if S3 is configured
@ -366,9 +375,9 @@ Resources:
Resource:
- Fn::If:
# Get bucket name depending if the user defines a bucket name or not
- S3RecordingsBucketNamePresent
- !Join [ "", [ 'arn:aws:s3:::', !Ref S3RecordingsBucketName ] ]
- CreateS3Bucket
- !Join [ "", [ 'arn:aws:s3:::', !Ref AWS::StackName, '-recordings' ] ]
- !Join [ "", [ 'arn:aws:s3:::', !Ref S3RecordingsBucketName ] ]
- Ref: AWS::NoValue
- Fn::If:
# Only apply this policy if S3 is configured
@ -393,7 +402,7 @@ Resources:
S3bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Join [ "", [ !Ref 'AWS::StackName', '-recordings' ] ]
BucketName: !Join ["" , [ !Ref AWS::StackName, '-recordings' ] ]
AccessControl: Private
PublicAccessBlockConfiguration:
BlockPublicAcls: true
@ -486,8 +495,9 @@ Resources:
fi
# S3 Configuration
if [ "${RecordingStorage}" == "s3" ]; then
sed -i "s/#OPENVIDU_PRO_RECORDING_STORAGE=/OPENVIDU_PRO_RECORDING_STORAGE=s3/" $WORKINGDIR/.env
if [ "${Recording}" != "disabled" ]; then
sed -i "s/OPENVIDU_RECORDING=false/OPENVIDU_RECORDING=true/" $WORKINGDIR/.env
sed -i "s/#OPENVIDU_PRO_RECORDING_STORAGE=/OPENVIDU_PRO_RECORDING_STORAGE=${Recording}/" $WORKINGDIR/.env
if [ ! -z "${S3RecordingsBucketName}" ]; then
sed -i "s/#OPENVIDU_PRO_AWS_S3_BUCKET=/OPENVIDU_PRO_AWS_S3_BUCKET=${S3RecordingsBucketName}/" $WORKINGDIR/.env
else
@ -495,7 +505,7 @@ Resources:
fi
fi
- kmsAmi: !FindInMap [KMSAMIMAP, !Ref 'AWS::Region', AMI]
s3BucketName: !Join [ "", [ !Ref 'AWS::StackName', '-recordings' ] ]
s3BucketName: !Join ["", [ !Ref AWS::StackName, '-recordings' ] ]
mode: "000755"
owner: "root"
group: "root"

View File

@ -132,12 +132,6 @@ OPENVIDU_PRO_CLUSTER_LOAD_STRATEGY=streams
# For example 192.168.1.101
# OPENVIDU_PRO_PRIVATE_IP=
# Whether to enable recording module or not
OPENVIDU_RECORDING=false
# Use recording module with debug mode.
OPENVIDU_RECORDING_DEBUG=false
# Where to store recording files. Can be “local” (local storage) or “s3” (AWS bucket).
# You will need to define a OPENVIDU_PRO_AWS_S3_BUCKET if you use it.
#OPENVIDU_PRO_RECORDING_STORAGE=
@ -166,6 +160,12 @@ OPENVIDU_RECORDING_DEBUG=false
# This property is only taken into account if OPENVIDU_PRO_RECORDING_STORAGE=s3
# OPENVIDU_PRO_AWS_REGION=
# Whether to enable recording module or not
OPENVIDU_RECORDING=false
# Use recording module with debug mode.
OPENVIDU_RECORDING_DEBUG=false
# Openvidu Folder Record used for save the openvidu recording videos. Change it
# with the folder you want to use from your host.
OPENVIDU_RECORDING_PATH=/opt/openvidu/recordings