Skip to content

Commit

Permalink
- Added RDS Aurora MySQL serverless support
Browse files Browse the repository at this point in the history
- Added non paco.ref support for EBS volume mounts
  • Loading branch information
gitwater committed Oct 4, 2021
1 parent 389ceda commit a0e6440
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
19 changes: 13 additions & 6 deletions src/paco/application/ec2_launch_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def add_secrets_function_policy(self, resource):
sed -i -e "s/$SED_PATTERN/$SECRET/" $REPLACE_FILE
}
# ec2lm_replace_secret_in_file_from_json <secret id> <file> <replace pattern> <secret name>
# ec2lm_replace_secret_in_file_from_json <secret id> <replace pattern> <file> <secret name>
function ec2lm_replace_secret_in_file_from_json() {
SECRET_ID=$1
SED_PATTERN=$2
Expand Down Expand Up @@ -1009,11 +1009,16 @@ def lb_add_ebs(self, bundle_name, resource):
if ebs_volume_mount.enabled == False:
continue
ebs_enabled = True
ebs_stack = resolve_ref(ebs_volume_mount.volume, self.paco_ctx.project, self.account_ctx)
ebs_stack_name = ebs_stack.get_name()

ebs_volume_id = ebs_volume_mount.volume
if is_ref(ebs_volume_mount.volume) == True:
ebs_stack = resolve_ref(ebs_volume_mount.volume, self.paco_ctx.project, self.account_ctx)
ebs_stack_name = ebs_stack.get_name()
ebs_volume_id = ebs_stack_name

process_mount_volumes += "process_volume_mount {} {} {} {}\n".format(
ebs_volume_mount.folder,
ebs_stack_name,
ebs_volume_id,
ebs_volume_mount.filesystem,
ebs_volume_mount.device
)
Expand Down Expand Up @@ -1070,14 +1075,16 @@ def lb_add_ebs(self, bundle_name, resource):
function process_volume_mount()
{{
MOUNT_FOLDER=$1
EBS_STACK_NAME=$2
EBS_VOLUME_ID=$2
FILESYSTEM=$3
EBS_DEVICE=$4
echo "EC2LM: EBS: Process Volume Mount: Begin"
# Get EBS Volume Id
EBS_VOLUME_ID=$(aws ec2 describe-volumes --filters Name=tag:aws:cloudformation:stack-name,Values=$EBS_STACK_NAME --query "Volumes[*].VolumeId | [0]" --region $REGION | tr -d '"')
if [[ "$EBS_VOLUME_ID" != "vol-"* ]]; then
EBS_VOLUME_ID=$(aws ec2 describe-volumes --filters Name=tag:aws:cloudformation:stack-name,Values=$EBS_VOLUME_ID --query "Volumes[*].VolumeId | [0]" --region $REGION | tr -d '"')
fi
# Setup the mount folder
if [ -e $MOUNT_FOLDER ] ; then
Expand Down
27 changes: 21 additions & 6 deletions src/paco/cftemplates/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ def __init__(self, stack, paco_ctx,):
if len(sg_param_ref_list) > 0:
db_cluster_dict['VpcSecurityGroupIds'] = sg_param_ref_list

# Backtracking
if rds_aurora.backtrack_window_in_seconds > 0:
db_cluster_dict['BacktrackWindow'] = rds_aurora.backtrack_window_in_seconds
if rds_aurora.engine_mode == 'serverless':
# Backtracking is not supported on serverless engine mode
# db_cluster_dict['BacktrackWindow'] = 0
db_cluster_dict['ScalingConfiguration'] = {
'AutoPause': True,
'MinCapacity': 1,
'MaxCapacity': 32,
'SecondsUntilAutoPause': 300
}
db_cluster_dict['Engine'] = 'aurora-mysql'

db_cluster_res = troposphere.rds.DBCluster.from_dict(
rds_cluster_logical_id,
db_cluster_dict
Expand Down Expand Up @@ -407,12 +421,13 @@ def __init__(self, stack, paco_ctx,):
value=troposphere.GetAtt(db_cluster_res, 'Endpoint.Port'),
ref=self.resource.paco_ref_parts + ".endpoint.port",
)
self.create_output(
title='ClusterReadEndpointAddress',
description='Cluster ReadEndpoint Address',
value=troposphere.GetAtt(db_cluster_res, 'ReadEndpoint.Address'),
ref=self.resource.paco_ref_parts + ".readendpoint.address",
)
if rds_aurora.engine_mode != 'serverless':
self.create_output(
title='ClusterReadEndpointAddress',
description='Cluster ReadEndpoint Address',
value=troposphere.GetAtt(db_cluster_res, 'ReadEndpoint.Address'),
ref=self.resource.paco_ref_parts + ".readendpoint.address",
)

# DNS - Route53 Record Set
if rds_aurora.is_dns_enabled() == True:
Expand Down
2 changes: 2 additions & 0 deletions src/paco/cftemplates/route53_hostedzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def __init__(self, stack, paco_ctx):
elif record_set_config.resource_records[0].find('elb.amazonaws.com') != -1:
elb_region = record_set_config.resource_records[0].split('.')[1]
hosted_zone_id = self.lb_hosted_zone_id('alb', elb_region)
elif record_set_config.resource_records[0].find('awsglobalaccelerator.com') != -1:
hosted_zone_id = 'Z2BJ6XQ5FK7U4H'
record_set_dict['AliasTarget'] = troposphere.route53.AliasTarget(
HostedZoneId=hosted_zone_id,
DNSName=record_set_config.resource_records[0]
Expand Down

0 comments on commit a0e6440

Please sign in to comment.