Skip to content

Commit 488cedd

Browse files
authored
Redis module (#53)
* Initial commit * Missing space * default boolean fix * var fixes here and there * Typo * numbering variables * Fixing defaults * nulling some * To supershort * Fixing nulls * Typo in secret name * Making redis connection secret optional * Small tweaks and typos fix * rocket * Typo * Fixing num_cache_cluster incompat with num_node_groups * Fixing var name * Fixing dynamics * Removing dynamic block * Adding cluster check to failover * Typo * Fix * Cosmetic details * Adding aws_redis_cloudwatch_retention_days * Typo * Fix * Adding maintenance options * Dynamic approach 2 * Fix * Dynamic x2 * Cosmetics * Adding aws_redis_automatic_failover * nulling default
1 parent 6d27de3 commit 488cedd

13 files changed

+786
-4
lines changed

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
1. [RDS](#rds-inputs)
6262
1. [Amazon Aurora Inputs](#aurora-inputs)
6363
1. [Docker](#docker-inputs)
64+
1. [Redis](#redis-inputs)
6465
1. [ECS](#ecs-inputs)
6566
1. [ECR](#ecr-inputs)
6667
1. [EKS](#eks-inputs)
@@ -305,6 +306,44 @@ The following inputs can be used as `step.with` keys
305306
<hr/>
306307
<br/>
307308

309+
#### **Redis Inputs**
310+
| Name | Type | Description |
311+
|------------------|---------|------------------------------------|
312+
| `aws_redis_enable` | Boolean | Enables the creation of a Redis instance. |
313+
| `aws_redis_user` | String | Redis username. Defaults to `redisuser`. |
314+
| `aws_redis_user_access_string` | String | String expression for user access. Defaults to `on ~* +@all`. |
315+
| `aws_redis_user_group_name` | String | User group name. Defaults to `aws_resource_identifier-redis`. |
316+
| `aws_redis_security_group_name` | String | Redis security group name. Defaults to `SG for aws_resource_identifier - Redis`. |
317+
| `aws_redis_ingress_allow_all` | Boolean | Allow access from 0.0.0.0/0. Defaults to `true`. |
318+
| `aws_redis_allowed_security_groups` | String | Comma separated list of security groups to be added to the Redis SG. |
319+
| `aws_redis_subnets` | String | Define a list of specific subnets where Redis will live. Defaults to all of the VPC ones. If nome defined, default VPC. |
320+
| `aws_redis_port` | String | Redis port. Defaults to `6379`. |
321+
| `aws_redis_at_rest_encryption` | Boolean | Encryption at rest. Defaults to `true`. |
322+
| `aws_redis_in_transit_encryption` | Boolean | In-transit encryption. Defaults to `true`. |
323+
| `aws_redis_replication_group_id` | String | Name of the Redis replication group. Defaults to `aws_resource_identifier-redis`. |
324+
| `aws_redis_node_type` | String | Node type of the Redis instance. Defaults to `cache.t2.small`. |
325+
| `aws_redis_num_cache_clusters` | String | Amount of Redis nodes. Defaults to `1`. |
326+
| `aws_redis_parameter_group_name` | String | Redis parameters groups name. If cluster wanted, set it to something that includes *.cluster.on.* Defaults to `default.redis7`. |
327+
| `aws_redis_num_node_groups` | String | Number of node groups. Defaults to `0`. |
328+
| `aws_redis_replicas_per_node_group` | String | Number of replicas per node group. Defaults to `0`. |
329+
| `aws_redis_multi_az_enabled` | Boolean | Enables multi-availability-zone redis. Defaults to `false`. |
330+
| `aws_redis_automatic_failover` | Boolean | Allows overriding the automatic configuration of this value, only needed when playing with resources in a non-conventional way. |
331+
| `aws_redis_apply_immediately` | Boolean | Specifies whether any modifications are applied immediately, or during the next maintenance window. Defaults to `false`. |
332+
| `aws_redis_auto_minor_upgrade` | Boolean | Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Defaults to `true`. |
333+
| `aws_redis_maintenance_window` | String | Specifies the weekly time range for when maintenance on the cache cluster is performed. Example:`sun:05:00-sun:06:00`. Defaults to `null`. |
334+
| `aws_redis_snapshot_window` | String | Daily time range (in UTC) when to start taking a daily snapshot. Minimum is a 60 minute period. Example: `05:00-09:00`. Defaults to `null`. |
335+
| `aws_redis_final_snapshot` | String | Change name to define a final snapshot. |
336+
| `aws_redis_snapshot_restore_name` | String | Set name to restore a snapshot to the cluster. The default behaviour is to restore it each time this action runs. |
337+
| `aws_redis_cloudwatch_enabled` | String | Enable or disables Cloudwatch logging. |
338+
| `aws_redis_cloudwatch_lg_name` | String | Cloudwatch log group name. Defaults to `/aws/redis/aws_resource_identifier` **Will append log_type to it** eg. `/your/name/slow-log`. |
339+
| `aws_redis_cloudwatch_log_format` | String | Define log format between `json`(default) and text. |
340+
| `aws_redis_cloudwatch_log_type` | String | Log type. Older Redis engines need `slow-log`. Newer support `engine-log` (default). You could add both by setting `slow-log,engine-log`. |
341+
| `aws_redis_cloudwatch_retention_days` | String | Number of days to retain cloudwatch logs. Defaults to `14`. |
342+
| `aws_redis_single_line_url_secret`| Boolean | Creates an AWS secret containing the connection string containing `protocol://user@pass:endpoint:port` |
343+
| `aws_redis_additional_tags` | String | Additional tags to be added to every Redis related resource. |
344+
<hr/>
345+
<br/>
346+
308347
#### **ECS Inputs***
309348
| Name | Type | Description |
310349
|------------------|---------|------------------------------------|

action.yaml

+145-1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,104 @@ inputs:
463463
description: 'A list of strings that will be added to created resources'
464464
required: false
465465

466+
# Redis
467+
aws_redis_enable:
468+
description: 'Enables the creation of a Redis instance'
469+
required: false
470+
aws_redis_user:
471+
description: 'Redis username. Defaults to redisuser'
472+
required: false
473+
aws_redis_user_access_string:
474+
description: 'String expression for user access. Defaults to on ~* +@all'
475+
required: false
476+
aws_redis_user_group_name:
477+
description: 'User group name. Defaults to aws_resource_identifier-redis'
478+
required: false
479+
aws_redis_security_group_name:
480+
description: 'Redis security group name. Defaults to SG for aws_resource_identifier - Redis'
481+
required: false
482+
aws_redis_ingress_allow_all:
483+
description: 'Allow access from 0.0.0.0/0 in the same VPC'
484+
required: false
485+
aws_redis_allowed_security_groups:
486+
description: 'Comma separated list of security groups to be added to the Redis SG.'
487+
required: false
488+
aws_redis_subnets:
489+
description: 'Define a list of specific subnets where Redis will live. Defaults to all of the VPC ones. If not defined, default VPC.'
490+
required: false
491+
aws_redis_port:
492+
description: 'Redis port. Defaults to 6379'
493+
required: false
494+
aws_redis_at_rest_encryption:
495+
description: 'Encryption at rest. Defaults to true.'
496+
required: false
497+
aws_redis_in_transit_encryption:
498+
description: 'In-transit encryption. Defaults to true.'
499+
required: false
500+
aws_redis_replication_group_id:
501+
description: 'Name of the Redis replication group. Defaults to aws_resource_identifier-redis'
502+
required: false
503+
aws_redis_node_type:
504+
description: 'Node type of the Redis instance. Defaults to cache.t2.small'
505+
required: false
506+
aws_redis_num_cache_clusters:
507+
description: 'Amount of Redis nodes. Defaults to 1'
508+
required: false
509+
aws_redis_parameter_group_name:
510+
description: 'Redis parameters groups name. If cluster wanted, set it to something that includes .cluster.on. Defaults to default.redis7'
511+
required: false
512+
aws_redis_num_node_groups:
513+
description: 'Number of node groups. Defaults to 0.'
514+
required: false
515+
aws_redis_replicas_per_node_group:
516+
description: 'Number of replicas per node group. Defaults to 0'
517+
required: false
518+
aws_redis_multi_az_enabled:
519+
description: 'Enables multi-availability-zone redis. Defaults to false'
520+
required: false
521+
aws_redis_automatic_failover:
522+
description: 'Allows overriding the automatic configuration of this value, only needed when playing with resources in a non-conventional way.'
523+
required: false
524+
aws_redis_apply_immediately:
525+
description: 'Specifies whether any modifications are applied immediately, or during the next maintenance window. Default is false.'
526+
required: false
527+
aws_redis_auto_minor_upgrade:
528+
description: 'Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Defaults to true.'
529+
required: false
530+
aws_redis_maintenance_window:
531+
description: 'Specifies the weekly time range for when maintenance on the cache cluster is performed. Example:sun:05:00-sun:06:00. Defaults to null.'
532+
required: false
533+
aws_redis_snapshot_window:
534+
description: 'Daily time range (in UTC) when to start taking a daily snapshot. Minimum is a 60 minute period. Example: 05:00-09:00. Defaults to null.'
535+
required: false
536+
aws_redis_final_snapshot:
537+
description: 'Change name to define a final snapshot.'
538+
required: false
539+
aws_redis_snapshot_restore_name:
540+
description: 'Set name to restore a snapshot to the cluster. The default behaviour is to restore it each time this action runs.'
541+
required: false
542+
aws_redis_cloudwatch_enabled:
543+
description: 'Enable or disables Cloudwatch logging.'
544+
required: false
545+
aws_redis_cloudwatch_lg_name:
546+
description: 'Cloudwatch log group name. Defaults to /aws/redis/aws_resource_identifier. Will append log_type to it.'
547+
required: false
548+
aws_redis_cloudwatch_log_format:
549+
description: 'Define log format between json (default) and text.'
550+
required: false
551+
aws_redis_cloudwatch_log_type:
552+
description: 'Log type. Older Redis engines need slow-log. Newer support engine-log (default)'
553+
required: false
554+
aws_redis_cloudwatch_retention_days:
555+
description: "Number of days to retain logs. 0 to never expire. Default '14'"
556+
reuired: false
557+
aws_redis_single_line_url_secret:
558+
description: 'Creates an AWS secret containing the connection string containing protocol://user@pass:endpoint:port'
559+
required: false
560+
aws_redis_additional_tags:
561+
description: 'Additional tags to be added to every Redis related resource'
562+
required: false
563+
466564
# Docker
467565
docker_install:
468566
description: 'Define if docker should be installed. After this, docker-compose up will be excecuted.'
@@ -775,7 +873,16 @@ outputs:
775873
ecr_repository_url:
776874
description: "ECR Repo URL"
777875
value: ${{ steps.deploy.outputs.ecr_repository_url }}
778-
876+
# REDIS
877+
redis_endpoint:
878+
description: "Redis Endpoint"
879+
value: ${{ steps.deploy.outputs.redis_endpoint }}
880+
redis_secret_name:
881+
description: "Redis Secret name"
882+
value: ${{ steps.deploy.outputs.redis_secret_name }}
883+
redis_connection_string_secret:
884+
description: "Redis secret containing complete URL to connect directly. (e.g. rediss://user:pass@host:port)"
885+
value: ${{ steps.deploy.outputs.redis_connection_string_secret }}
779886
runs:
780887
using: 'composite'
781888
steps:
@@ -959,6 +1066,40 @@ runs:
9591066
AWS_DB_PROXY_CLOUDWATCH_RETENTION_DAYS : ${{ inputs.aws_db_proxy_cloudwatch_retention_days }}
9601067
AWS_DB_PROXY_ADDITIONAL_TAGS: ${{ inputs.aws_db_proxy_additional_tags }}
9611068

1069+
# AWS REDIS
1070+
AWS_REDIS_ENABLE: ${{ inputs.aws_redis_enable }}
1071+
AWS_REDIS_USER: ${{ inputs.aws_redis_user }}
1072+
AWS_REDIS_USER_ACCESS_STRING: ${{ inputs.aws_redis_user_access_string }}
1073+
AWS_REDIS_USER_GROUP_NAME: ${{ inputs.aws_redis_user_group_name }}
1074+
AWS_REDIS_SECURITY_GROUP_NAME: ${{ inputs.aws_redis_security_group_name }}
1075+
AWS_REDIS_INGRESS_ALLOW_ALL: ${{ inputs.aws_redis_ingress_allow_all }}
1076+
AWS_REDIS_ALLOWED_SECURITY_GROUPS: ${{ inputs.aws_redis_allowed_security_groups }}
1077+
AWS_REDIS_SUBNETS: ${{ inputs.aws_redis_subnets }}
1078+
AWS_REDIS_PORT: ${{ inputs.aws_redis_port }}
1079+
AWS_REDIS_AT_REST_ENCRYPTION: ${{ inputs.aws_redis_at_rest_encryption }}
1080+
AWS_REDIS_IN_TRANSIT_ENCRYPTION: ${{ inputs.aws_redis_in_transit_encryption }}
1081+
AWS_REDIS_REPLICATION_GROUP_ID: ${{ inputs.aws_redis_replication_group_id }}
1082+
AWS_REDIS_NODE_TYPE: ${{ inputs.aws_redis_node_type }}
1083+
AWS_REDIS_NUM_CACHE_CLUSTER: ${{ inputs.aws_redis_num_cache_clusters }}
1084+
AWS_REDIS_PARAMETER_GROUP_NAME: ${{ inputs.aws_redis_parameter_group_name }}
1085+
AWS_REDIS_NUM_NODE_GROUPS: ${{ inputs.aws_redis_num_node_groups }}
1086+
AWS_REDIS_REPLICAS_PER_NODE_GROUP: ${{ inputs.aws_redis_replicas_per_node_group }}
1087+
AWS_REDIS_MULTI_AZ_ENABLED: ${{ inputs.aws_redis_multi_az_enabled }}
1088+
AWS_REDIS_AUTOMATIC_FAILOVER: ${{ inputs.aws_redis_automatic_failover }}
1089+
AWS_REDIS_APPLY_IMMEDIATELY: ${{ inputs.aws_redis_apply_immediately }}
1090+
AWS_REDIS_AUTO_MINOR_UPGRADE: ${{ inputs.aws_redis_auto_minor_upgrade }}
1091+
AWS_REDIS_MAINTENANCE_WINDOW: ${{ inputs.aws_redis_maintenance_window }}
1092+
AWS_REDIS_SNAPSHOT_WINDOW: ${{ inputs.aws_redis_snapshot_window }}
1093+
AWS_REDIS_FINAL_SNAPSHOT: ${{ inputs.aws_redis_final_snapshot }}
1094+
AWS_REDIS_SNAPSHOT_RESTORE_NAME: ${{ inputs.aws_redis_snapshot_restore_name }}
1095+
AWS_REDIS_CLOUDWATCH_ENABLED: ${{ inputs.aws_redis_cloudwatch_enabled }}
1096+
AWS_REDIS_CLOUDWATCH_LG_NAME: ${{ inputs.aws_redis_cloudwatch_lg_name }}
1097+
AWS_REDIS_CLOUDWATCH_LOG_FORMAT: ${{ inputs.aws_redis_cloudwatch_log_format }}
1098+
AWS_REDIS_CLOUDWATCH_LOG_TYPE: ${{ inputs.aws_redis_cloudwatch_log_type }}
1099+
AWS_REDIS_CLOUDWATCH_RETENTION_DAYS: ${{ inputs.aws_redis_cloudwatch_retention_days }}
1100+
AWS_REDIS_SINGLE_LINE_URL_SECRET: ${{ inputs.aws_redis_single_line_url_secret }}
1101+
AWS_REDIS_ADDITIONAL_TAGS: ${{ inputs.aws_redis_additional_tags }}
1102+
9621103
# Docker
9631104
DOCKER_INSTALL: ${{ inputs.docker_install }}
9641105
DOCKER_REMOVE_ORPHANS: ${{ inputs.docker_remove_orphans }}
@@ -1085,6 +1226,9 @@ runs:
10851226
ECS_DNS: ${{ steps.deploy.outputs.ecs_dns_record }}
10861227
ECR_REPO_ARN: ${{ steps.deploy.outputs.ecr_repository_arn }}
10871228
ECR_REPO_URL: ${{ steps.deploy.outputs.ecr_repository_url }}
1229+
REDIS_ENDPOINT: ${{ steps.deploy.outputs.redis_endpoint }}
1230+
REDIS_SECRET_NAME: ${{ steps.deploy.outputs.redis_secret_name }}
1231+
REDIS_SECRET_URL: ${{ steps.deploy.outputs.redis_connection_string_secret }}
10881232
run: $GITHUB_ACTION_PATH/operations/_scripts/deploy/summary.sh
10891233

10901234
# upload generated artifacts to GitHub if enabled

operations/_scripts/deploy/deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ if [[ $(alpha_only "$TF_STATE_BUCKET_DESTROY") == true ]] && ! [[ $(alpha_only "
8080
[[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] ||
8181
[[ $(alpha_only "$AWS_ECS_ENABLE") == true ]] ||
8282
[[ $(alpha_only "$AWS_DB_PROXY_ENABLE") == true ]] ||
83+
[[ $(alpha_only "$AWS_REDIS_ENABLE") == true ]] ||
8384
[[ $(alpha_only "$AWS_ECR_REPO_CREATE") == true ]] ||
8485
[[ $(alpha_only "$AWS_EKS_CREATE") == true ]]; then
8586
export TF_STATE_BUCKET_DESTROY="false"

operations/_scripts/deploy/summary.sh

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
# ECS_DNS
2323
# ECR_REPO_ARN
2424
# ECR_REPO_URL
25+
# REDIS_ENDPOINT
26+
# REDIS_SECRET_NAME
27+
# REDIS_SECRET_URL
2528

2629
# Create an error code mechanism so we don't have to check the actual static text,
2730
# just which case we fell into
@@ -41,6 +44,7 @@
4144
# 12 - success, Aurora created
4245
# 13 - success, DB Proxy created
4346
# 14 - success, ECS created
47+
# 15 - success, Redis created
4448
# 500 - cancelled
4549

4650
# Function to process and return the result as a string
@@ -122,6 +126,15 @@ if [[ $SUCCESS == 'success' ]]; then
122126
result_string="## Deploy Complete! :rocket:
123127
ECS LB Endpoing: ${ECS_ALB_DNS}
124128
ECS Public DNS: ${ECS_DNS}"
129+
elif [[ -n $REDIS_ENDPOINT ]] && [[ -n $REDIS_SECRET_NAME ]]; then
130+
SUMMARY_CODE=15
131+
result_string="## Deploy Complete! :rocket:
132+
Redis endpoint: ${REDIS_ENDPOINT}
133+
Redis secret name: ${REDIS_SECRET_NAME}"
134+
if [[ -n $REDIS_SECRET_URL ]]; then
135+
result_string+="
136+
Redis connection URL secret name: ${REDIS_SECRET_URL}"
137+
fi
125138
elif [[ $BITOPS_CODE_ONLY == 'true' ]]; then
126139
if [[ $BITOPS_CODE_STORE == 'true' ]]; then
127140
SUMMARY_CODE=6

operations/_scripts/generate/generate_bitops_config.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ if ([[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] ||
9595
[[ $(alpha_only "$AWS_AURORA_ENABLE") == true ]] ||
9696
[[ $(alpha_only "$AWS_RDS_DB_ENABLE") == true ]] ||
9797
[[ $(alpha_only "$AWS_ECS_ENABLE") == true ]] ||
98-
[[ $(alpha_only "$AWS_DB_PROXY_ENABLE") == true ]]) &&
98+
[[ $(alpha_only "$AWS_DB_PROXY_ENABLE") == true ]] ||
99+
[[ $(alpha_only "$AWS_REDIS_ENABLE") == true ]]) &&
99100
[[ "$(alpha_only $TF_STACK_DESTROY)" != "true" ]]; then
100101
# random_integer.az_select needs to be created before the "full stack" to avoid a potential state dependency locks
101102
targets="$targets
@@ -144,7 +145,7 @@ bitops:
144145
create_bitops_terraform_config aws false targets
145146
fi
146147
else
147-
if [[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") != "" ]] || [[ $(alpha_only "$AWS_EFS_ENABLE") != "" ]] || [[ "$AWS_AURORA_ENABLE" != "" ]] || [[ "$AWS_RDS_DB_ENABLE" != "" ]] || [[ "$AWS_ECS_ENABLE" != "" ]] || [[ "$AWS_RDS_PROXY_ENABLE" != "" ]]; then
148+
if [[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") != "" ]] || [[ $(alpha_only "$AWS_EFS_ENABLE") != "" ]] || [[ "$AWS_AURORA_ENABLE" != "" ]] || [[ "$AWS_RDS_DB_ENABLE" != "" ]] || [[ "$AWS_ECS_ENABLE" != "" ]] || [[ "$AWS_RDS_PROXY_ENABLE" != "" ]] || [[ "$AWS_REDIS_ENABLE" != "" ]]; then
148149
add_terraform_module aws
149150
create_bitops_terraform_config aws true targets
150151
fi

operations/_scripts/generate/generate_provider.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ provider \"aws\" {
6666
done
6767
}
6868

69-
generate_provider_aws aws ec2,r53,elb,efs,vpc,rds,aurora,ecs,db_proxy
69+
generate_provider_aws aws ec2,r53,elb,efs,vpc,rds,aurora,ecs,db_proxy,redis
7070
generate_provider_aws ecr ecr
7171
generate_provider_aws eks
7272

0 commit comments

Comments
 (0)