Skip to content

Commit 2699467

Browse files
authored
Fix ECR code (#84)
* Adding missing ecr * Moving ECR up * Adding ECR * fix AWS_ECR_REPO_CREATE * Enabling ECR back * Cleanup dupe code * Cleaning up
1 parent 6eb4a6e commit 2699467

File tree

10 files changed

+47
-423
lines changed

10 files changed

+47
-423
lines changed

operations/_scripts/generate/generate_bitops_config.sh

+4-13
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ if ([[ $(alpha_only "$AWS_EC2_INSTANCE_CREATE") == true ]] ||
9797
[[ $(alpha_only "$AWS_ECS_ENABLE") == true ]] ||
9898
[[ $(alpha_only "$AWS_DB_PROXY_ENABLE") == true ]] ||
9999
[[ $(alpha_only "$AWS_EKS_CREATE") == true ]] ||
100-
[[ $(alpha_only "$AWS_REDIS_ENABLE") == true ]]) &&
100+
[[ $(alpha_only "$AWS_REDIS_ENABLE") == true ]] ||
101+
[[ $(alpha_only "$AWS_ECR_REPO_CREATE") == true ]]) &&
101102
[[ "$(alpha_only $TF_STACK_DESTROY)" != "true" ]]; then
102103
# random_integer.az_select needs to be created before the "full stack" to avoid a potential state dependency locks
103104
targets="$targets
@@ -146,22 +147,12 @@ bitops:
146147
create_bitops_terraform_config aws false targets
147148
fi
148149
else
149-
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" != "" ]] || [[ "$AWS_EKS_CREATE" != "" ]]; then
150+
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" != "" ]] || [[ "$AWS_EKS_CREATE" != "" ]] || [[ "$AWS_ECR_REPO_CREATE" != "" ]]; then
150151
add_terraform_module aws
151152
create_bitops_terraform_config aws true targets
152153
fi
153154
fi
154-
if [[ $(alpha_only "$AWS_ECR_REPO_CREATE") != true ]]; then
155-
if check_statefile aws ecr; then
156-
add_terraform_module ecr
157-
create_bitops_terraform_config ecr false
158-
fi
159-
else
160-
if [[ $(alpha_only "$AWS_ECR_REPO_CREATE") == true ]]; then
161-
add_terraform_module ecr
162-
create_bitops_terraform_config ecr true
163-
fi
164-
fi
155+
165156
# Ansible Code part
166157

167158
if [[ "$(alpha_only $ANSIBLE_SKIP)" != "true" ]] && [[ "$(alpha_only $AWS_EC2_INSTANCE_CREATE)" == "true" ]]; then

operations/_scripts/generate/generate_provider.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ provider \"kubernetes\" {
7474
}" >> "${GITHUB_ACTION_PATH}/operations/deployment/terraform/$1/bitovi_provider.tf"
7575
}
7676

77-
generate_provider_aws aws ec2,r53,elb,efs,vpc,rds,aurora,ecs,db_proxy,redis,eks # Added eks here
78-
#generate_provider_aws ecr ecr
79-
#generate_provider_aws eks
77+
generate_provider_aws aws ec2,r53,elb,efs,vpc,rds,aurora,ecs,db_proxy,redis,eks,ecr
8078

8179
echo "Done with generate_provider.sh"

operations/_scripts/generate/generate_vars_terraform.sh

-40
Original file line numberDiff line numberDiff line change
@@ -717,44 +717,4 @@ $app_install_root
717717
718718
" > "${GITHUB_ACTION_PATH}/operations/deployment/terraform/aws/terraform.tfvars"
719719

720-
# -------------------------------------------------- #
721-
echo "
722-
#-- AWS --#
723-
$aws_resource_identifier
724-
$aws_resource_identifier_supershort
725-
$aws_additional_tags
726-
727-
#-- ECR --#
728-
$aws_ecr_repo_create
729-
$aws_ecr_repo_type
730-
$aws_ecr_repo_name
731-
$aws_ecr_repo_mutable
732-
$aws_ecr_repo_encryption_type
733-
$aws_ecr_repo_encryption_key_arn
734-
$aws_ecr_repo_force_destroy
735-
$aws_ecr_repo_image_scan
736-
$aws_ecr_registry_scan_rule
737-
$aws_ecr_registry_pull_through_cache_rules
738-
$aws_ecr_registry_scan_config
739-
$aws_ecr_registry_replication_rules_input
740-
$aws_ecr_repo_policy_attach
741-
$aws_ecr_repo_policy_create
742-
$aws_ecr_repo_policy_input
743-
$aws_ecr_repo_read_arn
744-
$aws_ecr_repo_write_arn
745-
$aws_ecr_repo_read_arn_lambda
746-
$aws_ecr_lifecycle_policy_input
747-
$aws_ecr_public_repo_catalog
748-
$aws_ecr_registry_policy_input
749-
$aws_ecr_additional_tags
750-
751-
#-- Application --#
752-
$ops_repo_environment
753-
$app_org_name
754-
$app_repo_name
755-
$app_branch_name
756-
757-
" > "${GITHUB_ACTION_PATH}/operations/deployment/terraform/ecr/terraform.tfvars"
758-
# We might want to pass only the variables needed and not all of them.
759-
760720
echo "Done with generate_vars_terraform.sh"

operations/deployment/terraform/aws/bitovi_main.tf

+42-31
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ module "db_proxy" {
372372

373373
module "proxy_dot_env" {
374374
source = "../modules/commons/dot_env"
375+
count = var.aws_aurora_proxy ? 1 : var.aws_db_proxy_enable ? 1 : var.aws_rds_db_proxy ? 1 : 0
375376
filename = "proxy.env"
376377
content = join("\n",[try(module.db_proxy_aurora[0].proxy_dot_env,""),try(module.db_proxy_rds[0].proxy_dot_env,""),try(module.db_proxy[0].proxy_dot_env,"")])
377378
depends_on = [ module.db_proxy_aurora,module.db_proxy_rds,module.db_proxy_rds ]
@@ -529,37 +530,37 @@ module "aws_route53_ecs" {
529530
}
530531
}
531532

532-
#module "aws_ecr" {
533-
# source = "../modules/aws/ecr"
534-
# count = var.aws_ecr_repo_create ? 1 : 0
535-
# # ECR
536-
# aws_ecr_repo_type = var.aws_ecr_repo_type
537-
# aws_ecr_repo_name = var.aws_ecr_repo_name
538-
# aws_ecr_repo_mutable = var.aws_ecr_repo_mutable
539-
# aws_ecr_repo_encryption_type = var.aws_ecr_repo_encryption_type
540-
# aws_ecr_repo_encryption_key_arn = var.aws_ecr_repo_encryption_key_arn
541-
# aws_ecr_repo_force_destroy = var.aws_ecr_repo_force_destroy
542-
# aws_ecr_repo_image_scan = var.aws_ecr_repo_image_scan
543-
# aws_ecr_registry_scan_rule = var.aws_ecr_registry_scan_rule
544-
# aws_ecr_registry_pull_through_cache_rules = var.aws_ecr_registry_pull_through_cache_rules
545-
# aws_ecr_registry_scan_config = var.aws_ecr_registry_scan_config
546-
# aws_ecr_registry_replication_rules_input = var.aws_ecr_registry_replication_rules_input
547-
# aws_ecr_repo_policy_attach = var.aws_ecr_repo_policy_attach
548-
# aws_ecr_repo_policy_create = var.aws_ecr_repo_policy_create
549-
# aws_ecr_repo_policy_input = var.aws_ecr_repo_policy_input
550-
# aws_ecr_repo_read_arn = var.aws_ecr_repo_read_arn
551-
# aws_ecr_repo_write_arn = var.aws_ecr_repo_write_arn
552-
# aws_ecr_repo_read_arn_lambda = var.aws_ecr_repo_read_arn_lambda
553-
# aws_ecr_lifecycle_policy_input = var.aws_ecr_lifecycle_policy_input
554-
# aws_ecr_public_repo_catalog = var.aws_ecr_public_repo_catalog
555-
# aws_ecr_registry_policy_input = var.aws_ecr_registry_policy_input
556-
# # Others
557-
# aws_resource_identifier = var.aws_resource_identifier
558-
#
559-
# providers = {
560-
# aws = aws.ecr
561-
# }
562-
#}
533+
module "aws_ecr" {
534+
source = "../modules/aws/ecr"
535+
count = var.aws_ecr_repo_create ? 1 : 0
536+
# ECR
537+
aws_ecr_repo_type = var.aws_ecr_repo_type
538+
aws_ecr_repo_name = var.aws_ecr_repo_name
539+
aws_ecr_repo_mutable = var.aws_ecr_repo_mutable
540+
aws_ecr_repo_encryption_type = var.aws_ecr_repo_encryption_type
541+
aws_ecr_repo_encryption_key_arn = var.aws_ecr_repo_encryption_key_arn
542+
aws_ecr_repo_force_destroy = var.aws_ecr_repo_force_destroy
543+
aws_ecr_repo_image_scan = var.aws_ecr_repo_image_scan
544+
aws_ecr_registry_scan_rule = var.aws_ecr_registry_scan_rule
545+
aws_ecr_registry_pull_through_cache_rules = var.aws_ecr_registry_pull_through_cache_rules
546+
aws_ecr_registry_scan_config = var.aws_ecr_registry_scan_config
547+
aws_ecr_registry_replication_rules_input = var.aws_ecr_registry_replication_rules_input
548+
aws_ecr_repo_policy_attach = var.aws_ecr_repo_policy_attach
549+
aws_ecr_repo_policy_create = var.aws_ecr_repo_policy_create
550+
aws_ecr_repo_policy_input = var.aws_ecr_repo_policy_input
551+
aws_ecr_repo_read_arn = var.aws_ecr_repo_read_arn
552+
aws_ecr_repo_write_arn = var.aws_ecr_repo_write_arn
553+
aws_ecr_repo_read_arn_lambda = var.aws_ecr_repo_read_arn_lambda
554+
aws_ecr_lifecycle_policy_input = var.aws_ecr_lifecycle_policy_input
555+
aws_ecr_public_repo_catalog = var.aws_ecr_public_repo_catalog
556+
aws_ecr_registry_policy_input = var.aws_ecr_registry_policy_input
557+
# Others
558+
aws_resource_identifier = var.aws_resource_identifier
559+
560+
providers = {
561+
aws = aws.ecr
562+
}
563+
}
563564

564565
module "eks" {
565566
source = "../modules/aws/eks"
@@ -824,6 +825,16 @@ output "redis_sg_id" {
824825
value = try(module.redis[0].redis_sg_id,null)
825826
}
826827

828+
# ECR
829+
830+
output "ecr_repository_arn" {
831+
value = try(module.aws_ecr[0].repository_arn,null)
832+
}
833+
834+
output "ecr_repository_url" {
835+
value = try(module.aws_ecr[0].repository_url,null)
836+
}
837+
827838
# EKS
828839
output "eks_cluster_name" {
829840
value = try(module.eks[0].aws_eks_cluster_name,null)

operations/deployment/terraform/ecr/aws_variables.tf

-173
This file was deleted.

0 commit comments

Comments
 (0)