Skip to content

Commit

Permalink
Print better results for rds ecs (#48)
Browse files Browse the repository at this point in the history
* Initial commit

* Cleaner Destroy message

* Adding index

* Typo in var

* Fixes in output

* Removing unnecesray output
  • Loading branch information
LeoDiazL authored Oct 20, 2023
1 parent 2017391 commit 6fdc99b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
18 changes: 18 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,20 @@ outputs:
instance_endpoint:
description: "The URL of the generated ec2 instance"
value: ${{ steps.deploy.outputs.instance_endpoint }}
# RDS
db_endpoint:
description: "ECS ALB DNS Record"
value: ${{ steps.deploy.outputs.db_endpoint }}
db_secret_details_name:
description: "ECS DNS URL"
value: ${{ steps.deploy.outputs.db_secret_details_name }}
# ECS
ecs_load_balancer_dns:
description: "ECS ALB DNS Record"
value: ${{ steps.deploy.outputs.ecs_load_balancer_dns }}
ecs_dns_record:
description: "ECS DNS URL"
value: ${{ steps.deploy.outputs.ecs_dns_record }}
# ECR
ecr_repository_arn:
description: "ECR Repo ARN"
Expand Down Expand Up @@ -951,6 +965,10 @@ runs:
TF_STATE_BUCKET_DESTROY: ${{ inputs.tf_state_bucket_destroy }}
AWS_EC2_PORT_LIST: ${{ inputs.aws_ec2_port_list }}
AWS_ELB_LISTEN_PORT: ${{ inputs.aws_elb_listen_port }}
RDS_ENDPOINT: ${{ steps.deploy.outputs.db_endpoint }}
RDS_SECRETS_NAME: ${{ steps.deploy.outputs.db_secret_details_name }}
ECS_ALB_DNS: ${{ steps.deploy.outputs.ecs_load_balancer_dns }}
ECS_DNS: ${{ steps.deploy.outputs.ecs_dns_record }}
ECR_REPO_ARN: ${{ steps.deploy.outputs.ecr_repository_arn }}
ECR_REPO_URL: ${{ steps.deploy.outputs.ecr_repository_url }}
run: $GITHUB_ACTION_PATH/operations/_scripts/deploy/summary.sh
Expand Down
2 changes: 1 addition & 1 deletion operations/_scripts/deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cat $GITHUB_ACTION_PATH/operations/deployment/bitops.config.yaml
## Ensuring bucket get's destroyed only if everything is set to be destroyed
if [[ $(alpha_only "$TF_STATE_BUCKET_DESTROY") == true ]] && ! [[ $(alpha_only "$TF_STACK_DESTROY") == true ]] ; then
if [[ $(alpha_only "$AWS_AURORA_ENABLE") == true ]] ||
[[ $(alpha_only "$AWS_RDS_ENABLE") == true ]] ||
[[ $(alpha_only "$AWS_RDS_DB_ENABLE") == true ]] ||
[[ $(alpha_only "$AWS_EFS_ENABLE") == true ]] ||
[[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] ||
[[ $(alpha_only "$AWS_ECS_ENABLE") == true ]] ||
Expand Down
24 changes: 22 additions & 2 deletions operations/_scripts/deploy/summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# TF_STATE_BUCKET_DESTROY
# AWS_EC2_PORT_LIST
# AWS_ELB_LISTEN_PORT
# RDS_ENDPOINT
# RDS_SECRETS_NAME
# ECS_ALB_DNS
# ECS_DNS
# ECR_REPO_ARN
# ECR_REPO_URL

Expand All @@ -28,6 +32,8 @@
# 8 - success, destroy buckets and infrastructure
# 9 - success, destroy infrastructure
# 10 - success, ECR created
# 11 - success. RDS created
# 12 - success, ECS created
# 500 - cancelled

# Function to process and return the result as a string
Expand Down Expand Up @@ -78,6 +84,20 @@ if [[ $SUCCESS == 'success' ]]; then
result_string="## Deploy Complete! :rocket:
ECR Repo ARN: ${ECR_REPO_ARN}
ECR Repo URL: ${ECR_REPO_URL}"
elif [[ -n $RDS_ENDPOINT ]] && [[ -n $RDS_SECRETS_NAME ]]; then
SUMMARY_CODE=11
result_string="## Deploy Complete! :rocket:
RDS Endpoint: ${RDS_ENDPOINT}
RDS Details Secret Manager name: ${RDS_SECRETS_NAME}"
elif [[ -n $ECS_ALB_DNS ]] && ![[ -n $ECS_DNS ]]; then
SUMMARY_CODE=12
result_string="## Deploy Complete! :rocket:
ECS LB Endpoint: ${ECS_ALB_DNS}"
elif [[ -n $ECS_ALB_DNS ]] && [[ -n $ECS_DNS ]]; then
SUMMARY_CODE=12
result_string="## Deploy Complete! :rocket:
ECS LB Endpoing: ${ECS_ALB_DNS}
ECS Public DNS: ${ECS_DNS}"
elif [[ $BITOPS_CODE_ONLY == 'true' ]]; then
if [[ $BITOPS_CODE_STORE == 'true' ]]; then
SUMMARY_CODE=6
Expand All @@ -94,11 +114,11 @@ if [[ $SUCCESS == 'success' ]]; then
elif [[ $TF_STACK_DESTROY == 'true' ]]; then
if [[ $TF_STATE_BUCKET_DESTROY != 'true' ]]; then
SUMMARY_CODE=9
result_string="## VM Destroyed! :boom:
result_string="## Destroyed! :boom:
Infrastructure should be gone now!"
else
SUMMARY_CODE=8
result_string="## VM Destroyed! :boom:
result_string="## Destroyed! :boom:
Buckets and infrastructure should be gone now!"
fi

Expand Down
2 changes: 0 additions & 2 deletions operations/_scripts/generate/generate_provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,4 @@ generate_provider_aws aws ec2,r53,elb,efs,vpc,rds,aurora,ecs
generate_provider_aws ecr ecr
generate_provider_aws eks

cat "${GITHUB_ACTION_PATH}/operations/deployment/terraform/aws/bitovi_provider.tf"

echo "Done with generate_provider.sh"
12 changes: 12 additions & 0 deletions operations/deployment/terraform/aws/bitovi_main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,18 @@ output "vm_url" {
value = try(module.aws_route53[0].vm_url,local.elb_url)
}

output "db_endpoint" {
value = try(module.rds[0].db_endpoint,null)
}

output "db_secret_details_name" {
value = try(module.rds[0].db_secret_details,null)
}

output "ecs_dns_record" {
value = try(module.aws_route53_ecs[0].vm_url,null)
}

output "ecs_load_balancer_dns" {
value = try(module.aws_ecs[0].load_balancer_dns,null)
}
9 changes: 4 additions & 5 deletions operations/deployment/terraform/modules/aws/rds/aws_rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ output "db_endpoint" {
value = aws_db_instance.default.endpoint
}

output "db_secret_details" {
value = aws_secretsmanager_secret.rds_database_credentials.name
}

// Creates a secret manager secret for the databse credentials
resource "aws_secretsmanager_secret" "rds_database_credentials" {
name = "${var.aws_resource_identifier_supershort}-rdsdb-pub-${random_string.random_sm.result}"
Expand All @@ -88,11 +92,6 @@ resource "aws_secretsmanager_secret_version" "database_credentials_sm_secret_ver
})
}

locals {
db_secret_name = aws_secretsmanager_secret_version.database_credentials_sm_secret_version_dev.id
db_port = aws_db_instance.default.port
}

resource "random_password" "rds" {
length = 25
special = false
Expand Down

0 comments on commit 6fdc99b

Please sign in to comment.