-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Terraform scripts to work with latest Terraform AWS provider and RDS module #1001
Conversation
This should enable each AWS user to create their own DB parameter group which will allow it to be deleted when terraform destroy is executed by any AWS user.
ap-northeast-1 is Japan which is the default regions used by HK developers. ap-northeast-2 is Seoul which is also for dev work.
This is a WIP for an updated policy-rds.md that is more tidy. N.B. That rds:ModifyDBParameterGroup is in the CreateResourcesforRDSInstances section. For some unknown reason, I will not work in the ManageDBParameterGroupsWithOwnerTagRestriction section.
This reference is to provide the name of the gigadb db parameter group for the parameter_group_name variable in db module.
CreateDBParameterGroup permission moved to CreateResourcesforRDSInstances section. CreateDBParameterGroup was originally in ManageDBParameterGroupsWithOwnerTagRestriction section but this was causing problems with creating DB parameter groups.
Seems like we need to provide the path to the directory with the .tfstate file. Adding ./ does this. See adammck/terraform-inventory#121
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pli888,
I was able to perform all the provisioning steps and they all worked fine.
I was able to ssh the bastion the usual way I do with no problems:
$ ssh -i *************.pem [email protected]
and I could ssh the webapp ec2 instance the usual way I do without problems:
$ ssh -i *************.pem -o ProxyCommand='ssh -i *************.pem -vvv -W %h:%p -q [email protected]' [email protected]
All the tests are passing locally and on CI, and the staging deployment sd_deploy
was successful and the website on my staging environment and
the corresponding portainer dashboard seem to work fine.
Finally terraform destroy
did its job without errors.
I'm therefore happy to approve this PR.
Probably a stupid question:
In aws_db_parameter_group.gigadb-db-param-group[0].name
, why is there [0]
? I would think the DB parameter group resource is one thing, not an array of things.
It's because we use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pli888,
I have gone through all the steps mentioned in How to test the new feature
and everything is working well as expected.
The gigadb_db_host
is accessible on bastion server, and dockerhost server is accessible through the bastion server using ProxyCommadn
from local dev computer.
And I have tried several rounds of terraform apply
and terraform apply --destroy
, DB parameter group can be created and destroyed successfully.
A suggestion is to move create_database_subnet_group = true
in terraform.tf to above the comment block, so it would make the content below it more consistent. It is just a minor, cosmetic change.
Other than that, all code looks good to me.
Pull request for issue: #995 terraform plan causes unsupported argument errors
This is a pull request for the following functionalities:
How to test the new feature
/gigadb-website/ops/infrastructure/envs/staging
environment directory and ensure that it contains only the.gitignore
file.../../../scripts/tf_init.sh --project gigascience/forks/<YOUR_GITHUB_USERNAME>-gigadb-website --env staging
. This should download the latest version 4.8.0 AWS provider for Terraform.terraform plan
terraform apply
- you should have the required permissions to create the AWS resources because there is a new IAM policyRDSPolicy_PR1001
containing the contents ofdocs/awsdocs/policy-rds.md
in this PR which I have already attached to your AWS user accounts.terraform refresh
.../../../scripts/ansible_init.sh --env staging
ansible-playbook -i ../../inventories bastion_playbook.yml
TF_KEY_NAME=private_ip ansible-playbook -i ../../inventories dockerhost_playbook.yml
ec2_dockerhost
instance from localhost:ec2_dockerhost
instance from localhost via bastion:Code Changes
Changes to the provisioning
policy-rds.md
has been updated to moveCreateDBParameterGroup
andModifyDBParameterGroup
permissions into theCreateResourcesforRDSInstances
section. Originally, the permission was in theCreateRDSInstancesWithRegionAndInstanceTypeRestriction
section but this now stops the DB parameter group from being created. There are other cosmetic changes inpolicy-rds.md
.ops/infrastructure/modules/rds-instance/input.tf
has been updated to includevpc_database_subnet_group
variable which is now required for instantiating an RDS instance when using the latest version of Terraform AWS module.rds-instance.tf
has been updated to work with the latest Terraform AWS module version. The variablesname
andfinal_snapshot_identifier
are now calleddb_name
andfinal_snapshot_identifier_prefix
, respectively. In addition, theaws_db_parameter_group.gigadb-db-param-group
resource has a name which has the AWS owner's name appended to it. In addition, theparameter_group_name
in the rds module is provided using a reference to the name for theaws_db_parameter_group.gigadb-db-param-group
resource.Error deleting DB parameter group: InvalidDBParameterGroupState: One or more database instances are still members
error message which I don't see anymore when executingterraform destroy
.ops/infrastructure/terraform.tf
has been updated:terraform-inventory.sh
andansible_init.sh
were required to include./
at the end ofterraform-inventory.sh
calls to provide the location of the .tfstate file - see here for details.