version: 0.2 env: parameter-store: sg_ports: /demo/dbdevops/target/db/sg_ports cidr_blocks: /demo/dbdevops/target/infra/cidr_blocks subnet_ids: /demo/dbdevops/target/infra/subnet_ids exported-variables: - sg_ports - subnet_ids - cidr_blocks phases: install: commands: #Terraform Install - apt update - apt -y install curl - curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - - apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - apt update - apt -y install terraform=1.3.6 build: commands: - "cd ${CODEBUILD_SRC_DIR}/db-provisioning/db-provisioning-code" - "export TF_VAR_allocated_storage=#{precheckVariables.allocated_storage}" - "export TF_VAR_backup_retention_period=#{precheckVariables.backup_retention_period}" - "export TF_VAR_db_name=#{precheckVariables.dbname}" - "export TF_VAR_engine=#{precheckVariables.engine}" - "export TF_VAR_engine_version=#{precheckVariables.engine_version}" - "export TF_VAR_family=#{precheckVariables.family}" - "export TF_VAR_host=#{precheckVariables.host}" - "export TF_VAR_instance_class=#{precheckVariables.instace_class}" - "export TF_VAR_max_allocated_storage=#{precheckVariables.max_allocated_storage}" - "export TF_VAR_name=#{precheckVariables.name}" - "export TF_VAR_parameter_group_name=#{precheckVariables.parameter_group_name}" - "export TF_VAR_password=#{precheckVariables.password}" - "export TF_VAR_port=#{precheckVariables.port}" - "export TF_VAR_ssl_mode=#{precheckVariables.ssl_mode}" - "export TF_VAR_transit=#{precheckVariables.transit}" - "export TF_VAR_username=#{precheckVariables.username}" - "export TF_VAR_subnet_ids=${subnet_ids}" - "export TF_VAR_vpc_id=#{precheckVariables.vpc_id}" - "export TF_VAR_env=#{precheckVariables.environment}" - "export TF_VAR_region=#{precheckVariables.aws_region}" - "export TF_VAR_project_code=#{precheckVariables.project_code}" - "export TF_VAR_client=#{precheckVariables.client}" - "export TF_VAR_identifier=#{precheckVariables.identifier}" - "export TF_VAR_sg_ports=${sg_ports}" - "export TF_VAR_cidr_blocks=${cidr_blocks}" - "terraform init" - "echo ## TERRAFORM Destroy : Starting with the Terraform Destroy" - "terraform destroy -lock=false --auto-approve" artifacts: files: - '**/*'