fixed bugs for attached RDS
This commit is contained in:
parent
4db52814cd
commit
9aeeb0757c
|
@ -10,7 +10,7 @@
|
||||||
roles/main_infra/files/backend.tfvars
|
roles/main_infra/files/backend.tfvars
|
||||||
roles/main_infra/files/remote-backend-selector.tf
|
roles/main_infra/files/remote-backend-selector.tf
|
||||||
roles/main_infra/files/terraform.tfvars
|
roles/main_infra/files/terraform.tfvars
|
||||||
|
*.backup
|
||||||
|
|
||||||
# Sensitive information
|
# Sensitive information
|
||||||
/*.privkey
|
/*.privkey
|
||||||
|
|
10
README.md
10
README.md
|
@ -189,7 +189,15 @@ You can easily manipulate your deployment from any machine with sufficient prere
|
||||||
|
|
||||||
## Attaching the existing RDS instance to the current deployment
|
## Attaching the existing RDS instance to the current deployment
|
||||||
|
|
||||||
In some cases you may want not to create a new database, but to add the existing one to use within the deployment. In order to do that configure all the proper values at `group_vars/all.yml` including yours DB ID and name and execute the `ansible-playbook attach_existing_rds.yml` command. This will add the current DB instance into TF managed resource group. After that run `ansible-playbook deploy.yml` as usually.
|
In some cases you may want not to create a new database, but to add the existing one to use within the deployment. In order to do that configure all the proper values at `group_vars/all.yml` including yours DB ID and name and execute the `ansible-playbook attach_existing_rds.yml` command. This will add the current DB instance into Terraform-managed resource group. After that run `ansible-playbook deploy.yml` as usually.
|
||||||
|
|
||||||
|
Note 1: that this action includes creating the S3 and DynamoDB (if `backend` variable is set to `true`) to store Terraform state files.
|
||||||
|
|
||||||
|
Note 2: the actual name of your resource must include prefix that you will use in this deployment!
|
||||||
|
Example:
|
||||||
|
Real resource: tf-poa
|
||||||
|
prefix variable: tf
|
||||||
|
db_id variable: poa
|
||||||
|
|
||||||
## Common Errors and Questions
|
## Common Errors and Questions
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
- { role: s3, when: "backend|bool == true" }
|
- { role: s3, when: "backend|bool == true" }
|
||||||
- { role: dynamodb, when: "backend|bool == true" }
|
- { role: dynamodb, when: "backend|bool == true" }
|
||||||
- { role: attach_existing_rds }
|
- { role: attach_existing_rds }
|
||||||
|
vars_prompt:
|
||||||
|
- name: "confirmation"
|
||||||
|
prompt: "Are you sure you want to attach the existing RDS? If backend variable is set to True, this action includes creating the S3 and DynamoDB table for storing Terraform state files."
|
||||||
|
default: False
|
||||||
environment:
|
environment:
|
||||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||||
|
|
|
@ -36,7 +36,6 @@ prefix: "sokol"
|
||||||
|
|
||||||
## The following settings are related to the RDS instance which will be created during deployment
|
## The following settings are related to the RDS instance which will be created during deployment
|
||||||
db_id: "poa"
|
db_id: "poa"
|
||||||
db_name: "poa"
|
|
||||||
db_username: "username"
|
db_username: "username"
|
||||||
db_password: "qwerty12345"
|
db_password: "qwerty12345"
|
||||||
db_instance_class: "db.m4.xlarge"
|
db_instance_class: "db.m4.xlarge"
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
when: backend|bool == true
|
when: backend|bool == true
|
||||||
|
|
||||||
#Workaround since terraform module return unexpected error.
|
#Workaround since terraform module return unexpected error.
|
||||||
- name: Terraform provisioning
|
- name: Attach RDS to the current deployment
|
||||||
shell: "echo yes | {{ terraform_location }} {{ item }}"
|
shell: "echo yes | {{ terraform_location }} {{ item }}"
|
||||||
args:
|
args:
|
||||||
chdir: "roles/main_infra/files"
|
chdir: "roles/main_infra/files"
|
||||||
with_items:
|
with_items:
|
||||||
- "init{{ ' -backend-config=backend.tfvars' if backend|bool == true else '' }}"
|
- "init{{ ' -backend-config=backend.tfvars' if backend|bool == true else '' }}"
|
||||||
- "import aws_db_instance.default {{ db_id }}"
|
- "import aws_db_instance.default {{ prefix }}-{{ db_id }}"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
resource "aws_db_instance" "default" {
|
resource "aws_db_instance" "default" {
|
||||||
name = "${var.prefix}-${var.db_name}"
|
|
||||||
identifier = "${var.prefix}-${var.db_id}"
|
identifier = "${var.prefix}-${var.db_id}"
|
||||||
engine = "postgres"
|
engine = "postgres"
|
||||||
engine_version = "10.5"
|
engine_version = "10.5"
|
||||||
|
|
|
@ -45,7 +45,6 @@ variable "chain_network_icon" {
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "db_id" {}
|
variable "db_id" {}
|
||||||
variable "db_name" {}
|
|
||||||
variable "db_username" {}
|
variable "db_username" {}
|
||||||
variable "db_password" {}
|
variable "db_password" {}
|
||||||
variable "db_storage" {}
|
variable "db_storage" {}
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
|
|
||||||
- name: Show Terraform plan
|
- name: Show Terraform plan
|
||||||
debug:
|
debug:
|
||||||
var: tf_plan.stdout_lines
|
var: tf_plan.results[1].stdout_lines
|
||||||
|
|
||||||
- name: User prompt
|
- name: User prompt
|
||||||
pause:
|
pause:
|
||||||
prompt: "Are you absolutely sure you want to execute the deployment plan shown above? [Yes/No] Default: No"
|
prompt: "Are you absolutely sure you want to execute the deployment plan shown above? [False]"
|
||||||
register: user_answer
|
register: user_answer
|
||||||
|
|
||||||
- name: Terraform provisioning
|
- name: Terraform provisioning
|
||||||
|
|
|
@ -11,7 +11,6 @@ root_block_size = "{{ root_block_size }}"
|
||||||
pool_size = "{{ pool_size }}"
|
pool_size = "{{ pool_size }}"
|
||||||
|
|
||||||
db_id = "{{ db_id }}"
|
db_id = "{{ db_id }}"
|
||||||
db_name = "{{ db_name }}"
|
|
||||||
db_username = "{{ db_username }}"
|
db_username = "{{ db_username }}"
|
||||||
db_password = "{{ db_password }}"
|
db_password = "{{ db_password }}"
|
||||||
db_instance_class = "{{ db_instance_class }}"
|
db_instance_class = "{{ db_instance_class }}"
|
||||||
|
|
Loading…
Reference in New Issue