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

View File

@ -132,12 +132,6 @@ OPENVIDU_PRO_CLUSTER_LOAD_STRATEGY=streams
# For example 192.168.1.101 # For example 192.168.1.101
# OPENVIDU_PRO_PRIVATE_IP= # 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). # 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. # You will need to define a OPENVIDU_PRO_AWS_S3_BUCKET if you use it.
#OPENVIDU_PRO_RECORDING_STORAGE= #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 # This property is only taken into account if OPENVIDU_PRO_RECORDING_STORAGE=s3
# OPENVIDU_PRO_AWS_REGION= # 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 # Openvidu Folder Record used for save the openvidu recording videos. Change it
# with the folder you want to use from your host. # with the folder you want to use from your host.
OPENVIDU_RECORDING_PATH=/opt/openvidu/recordings OPENVIDU_RECORDING_PATH=/opt/openvidu/recordings