Skip to content

Commit 6fdc99b

Browse files
authored
Print better results for rds ecs (#48)
* Initial commit * Cleaner Destroy message * Adding index * Typo in var * Fixes in output * Removing unnecesray output
1 parent 2017391 commit 6fdc99b

File tree

6 files changed

+57
-10
lines changed

6 files changed

+57
-10
lines changed

action.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,20 @@ outputs:
669669
instance_endpoint:
670670
description: "The URL of the generated ec2 instance"
671671
value: ${{ steps.deploy.outputs.instance_endpoint }}
672+
# RDS
673+
db_endpoint:
674+
description: "ECS ALB DNS Record"
675+
value: ${{ steps.deploy.outputs.db_endpoint }}
676+
db_secret_details_name:
677+
description: "ECS DNS URL"
678+
value: ${{ steps.deploy.outputs.db_secret_details_name }}
679+
# ECS
680+
ecs_load_balancer_dns:
681+
description: "ECS ALB DNS Record"
682+
value: ${{ steps.deploy.outputs.ecs_load_balancer_dns }}
683+
ecs_dns_record:
684+
description: "ECS DNS URL"
685+
value: ${{ steps.deploy.outputs.ecs_dns_record }}
672686
# ECR
673687
ecr_repository_arn:
674688
description: "ECR Repo ARN"
@@ -951,6 +965,10 @@ runs:
951965
TF_STATE_BUCKET_DESTROY: ${{ inputs.tf_state_bucket_destroy }}
952966
AWS_EC2_PORT_LIST: ${{ inputs.aws_ec2_port_list }}
953967
AWS_ELB_LISTEN_PORT: ${{ inputs.aws_elb_listen_port }}
968+
RDS_ENDPOINT: ${{ steps.deploy.outputs.db_endpoint }}
969+
RDS_SECRETS_NAME: ${{ steps.deploy.outputs.db_secret_details_name }}
970+
ECS_ALB_DNS: ${{ steps.deploy.outputs.ecs_load_balancer_dns }}
971+
ECS_DNS: ${{ steps.deploy.outputs.ecs_dns_record }}
954972
ECR_REPO_ARN: ${{ steps.deploy.outputs.ecr_repository_arn }}
955973
ECR_REPO_URL: ${{ steps.deploy.outputs.ecr_repository_url }}
956974
run: $GITHUB_ACTION_PATH/operations/_scripts/deploy/summary.sh

operations/_scripts/deploy/deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ cat $GITHUB_ACTION_PATH/operations/deployment/bitops.config.yaml
7575
## Ensuring bucket get's destroyed only if everything is set to be destroyed
7676
if [[ $(alpha_only "$TF_STATE_BUCKET_DESTROY") == true ]] && ! [[ $(alpha_only "$TF_STACK_DESTROY") == true ]] ; then
7777
if [[ $(alpha_only "$AWS_AURORA_ENABLE") == true ]] ||
78-
[[ $(alpha_only "$AWS_RDS_ENABLE") == true ]] ||
78+
[[ $(alpha_only "$AWS_RDS_DB_ENABLE") == true ]] ||
7979
[[ $(alpha_only "$AWS_EFS_ENABLE") == true ]] ||
8080
[[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] ||
8181
[[ $(alpha_only "$AWS_ECS_ENABLE") == true ]] ||

operations/_scripts/deploy/summary.sh

+22-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# TF_STATE_BUCKET_DESTROY
1212
# AWS_EC2_PORT_LIST
1313
# AWS_ELB_LISTEN_PORT
14+
# RDS_ENDPOINT
15+
# RDS_SECRETS_NAME
16+
# ECS_ALB_DNS
17+
# ECS_DNS
1418
# ECR_REPO_ARN
1519
# ECR_REPO_URL
1620

@@ -28,6 +32,8 @@
2832
# 8 - success, destroy buckets and infrastructure
2933
# 9 - success, destroy infrastructure
3034
# 10 - success, ECR created
35+
# 11 - success. RDS created
36+
# 12 - success, ECS created
3137
# 500 - cancelled
3238

3339
# Function to process and return the result as a string
@@ -78,6 +84,20 @@ if [[ $SUCCESS == 'success' ]]; then
7884
result_string="## Deploy Complete! :rocket:
7985
ECR Repo ARN: ${ECR_REPO_ARN}
8086
ECR Repo URL: ${ECR_REPO_URL}"
87+
elif [[ -n $RDS_ENDPOINT ]] && [[ -n $RDS_SECRETS_NAME ]]; then
88+
SUMMARY_CODE=11
89+
result_string="## Deploy Complete! :rocket:
90+
RDS Endpoint: ${RDS_ENDPOINT}
91+
RDS Details Secret Manager name: ${RDS_SECRETS_NAME}"
92+
elif [[ -n $ECS_ALB_DNS ]] && ![[ -n $ECS_DNS ]]; then
93+
SUMMARY_CODE=12
94+
result_string="## Deploy Complete! :rocket:
95+
ECS LB Endpoint: ${ECS_ALB_DNS}"
96+
elif [[ -n $ECS_ALB_DNS ]] && [[ -n $ECS_DNS ]]; then
97+
SUMMARY_CODE=12
98+
result_string="## Deploy Complete! :rocket:
99+
ECS LB Endpoing: ${ECS_ALB_DNS}
100+
ECS Public DNS: ${ECS_DNS}"
81101
elif [[ $BITOPS_CODE_ONLY == 'true' ]]; then
82102
if [[ $BITOPS_CODE_STORE == 'true' ]]; then
83103
SUMMARY_CODE=6
@@ -94,11 +114,11 @@ if [[ $SUCCESS == 'success' ]]; then
94114
elif [[ $TF_STACK_DESTROY == 'true' ]]; then
95115
if [[ $TF_STATE_BUCKET_DESTROY != 'true' ]]; then
96116
SUMMARY_CODE=9
97-
result_string="## VM Destroyed! :boom:
117+
result_string="## Destroyed! :boom:
98118
Infrastructure should be gone now!"
99119
else
100120
SUMMARY_CODE=8
101-
result_string="## VM Destroyed! :boom:
121+
result_string="## Destroyed! :boom:
102122
Buckets and infrastructure should be gone now!"
103123
fi
104124

operations/_scripts/generate/generate_provider.sh

-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,4 @@ generate_provider_aws aws ec2,r53,elb,efs,vpc,rds,aurora,ecs
7070
generate_provider_aws ecr ecr
7171
generate_provider_aws eks
7272

73-
cat "${GITHUB_ACTION_PATH}/operations/deployment/terraform/aws/bitovi_provider.tf"
74-
7573
echo "Done with generate_provider.sh"

operations/deployment/terraform/aws/bitovi_main.tf

+12
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,18 @@ output "vm_url" {
453453
value = try(module.aws_route53[0].vm_url,local.elb_url)
454454
}
455455

456+
output "db_endpoint" {
457+
value = try(module.rds[0].db_endpoint,null)
458+
}
459+
460+
output "db_secret_details_name" {
461+
value = try(module.rds[0].db_secret_details,null)
462+
}
463+
464+
output "ecs_dns_record" {
465+
value = try(module.aws_route53_ecs[0].vm_url,null)
466+
}
467+
456468
output "ecs_load_balancer_dns" {
457469
value = try(module.aws_ecs[0].load_balancer_dns,null)
458470
}

operations/deployment/terraform/modules/aws/rds/aws_rds.tf

+4-5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ output "db_endpoint" {
7070
value = aws_db_instance.default.endpoint
7171
}
7272

73+
output "db_secret_details" {
74+
value = aws_secretsmanager_secret.rds_database_credentials.name
75+
}
76+
7377
// Creates a secret manager secret for the databse credentials
7478
resource "aws_secretsmanager_secret" "rds_database_credentials" {
7579
name = "${var.aws_resource_identifier_supershort}-rdsdb-pub-${random_string.random_sm.result}"
@@ -88,11 +92,6 @@ resource "aws_secretsmanager_secret_version" "database_credentials_sm_secret_ver
8892
})
8993
}
9094

91-
locals {
92-
db_secret_name = aws_secretsmanager_secret_version.database_credentials_sm_secret_version_dev.id
93-
db_port = aws_db_instance.default.port
94-
}
95-
9695
resource "random_password" "rds" {
9796
length = 25
9897
special = false

0 commit comments

Comments
 (0)