Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mongoexpuser/terraform-created-resources
Terraform module for creation of resources on public clouds platforms.
https://github.com/mongoexpuser/terraform-created-resources
aws bash hcl iac linode mongodb nodejs
Last synced: 26 days ago
JSON representation
Terraform module for creation of resources on public clouds platforms.
- Host: GitHub
- URL: https://github.com/mongoexpuser/terraform-created-resources
- Owner: MongoExpUser
- License: mit
- Created: 2020-04-13T05:58:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T22:51:44.000Z (almost 4 years ago)
- Last Synced: 2024-11-28T10:12:21.585Z (3 months ago)
- Topics: aws, bash, hcl, iac, linode, mongodb, nodejs
- Language: HCL
- Homepage:
- Size: 119 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#
# Terraform-Created-ResourcesTerraform module for creation of resources on public cloud platforms.
The following public cloud platforms and resources are currently covered:
1) ```AWS``` - EC2 and Lightsails instances (VMs) with Node.js and MongoDB installations.
Note 1: Node.js is installed on the the web server instance(s).
Note 2: Node.js and MongoDB are installed on the db server instance(s).
Note 3: Node.js installation can be disabled on the db server instance(s):
a) By setting the variable ```enable_web_server```, in the ```init_mongodb_server.sh``` file to ```false```.
b) See line 30 of ```init_mongodb_server.sh``` file.
2) ```Linode``` - Linode instances (VMs) with Node.js and MongoDB installations.
Note 1: Node.js and MongoDB are installed on the web server instance(s).
Note 2: MongoDB installation can be disabled on the web server instance(s):
a) By setting the variable, ```enable_mongodb_server```, to ```false``` in the ```startup script```
b) See line 122 of the ```main.tf``` file, where ```linode_stackscript_init``` is defined.This repo is based on ```Terraform Version 0.14.4```.
## RUNNING MODULE
### To run the module to create resources on ```AWS```:
1) Save or download the start-up bash file(s) in the link(s) below to the current working directory (CWD):
a) https://raw.githubusercontent.com/MongoExpUser/Terraform-Created-Resources/master/init_web_server.sh
b) https://raw.githubusercontent.com/MongoExpUser/Terraform-Created-Resources/master/init_mongodb_server.sh2) Also, copy the following script into a file (base.tf) in the current working directory:
```hcl
# define credential variable(s) of provider(s)
variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "aws_region" {}
variable "create_aws_resources" {default = 1}# define provider(s)
provider "aws" {
access_key = var.aws_access_key
secret_key = var.aws_secret_key
region = var.aws_region
}# create resource(s)
module "public_cloud_resources" {
source = "git::https://github.com/MongoExpUser/Terraform-Created-Resources.git"
}# create output(s)
output "ec2_web_server_instances" {
description = "A list of all created EC2 web server instances"
# the list contains key-value pairs of each instance's attributes
value = module.public_cloud_resources.aws_ec2_web_servers
}output "ec2_db_server_instances" {
description = "A list of all created EC2 db server instances"
# the list contains key-value pairs of each instance's attributes
value = module.public_cloud_resources.aws_ec2_db_servers
}output "lightsail_web_server_instances" {
description = "A list of all created AWS lightsail web server instances"
# the list contains key-value pairs of each instance's attributes
value = module.public_cloud_resources.aws_lightsail_web_servers
}output "lightsail_db_server_instances" {
description = "A list of all created AWS lightsail db server instances"
# the list contains key-value pairs of each instance's attributes
value = module.public_cloud_resources.aws_lightsail_db_servers
}output "lightsail_web_server_static_ips" {
description = "A list of all created AWS lightsail static ips"
# the list contains key-value pairs of each instance's attributes
value = module.public_cloud_resources.aws_lightsail_web_server_static_ips
}output "lightsail_db_server_static_ips" {
description = "A list of all created AWS lightsail static ips"
# the list contains key-value pairs of each instance's attributes
value = module.public_cloud_resources.aws_lightsail_db_server_static_ips
}```
3) Finally, execute the module from the base file (base.tf) in the current working directory (CWD) by typing the following commands at the prompt (assuming running via ```bash``` with ```sudo``` access):
```bash
#1) run init
sudo terraform init
#2) run terraform plan
sudo TF_VAR_aws_access_key="access-key-value" \
TF_VAR_aws_secret_key="secret-key-value" \
TF_VAR_aws_region="aws-region-value" \
terraform plan
#3) run terraform apply
sudo TF_VAR_aws_access_key="access-key-value" \
TF_VAR_aws_secret_key="secret-key-value" \
TF_VAR_aws_region="aws-region-value" \
terraform apply
```### To run the module to create resources on ```Linode```:
1) Copy the following script into a file (base.tf) in the current working directory:
```hcl
# define credential variable(s) of provider(s)
variable "linode_token_value" {}
variable "create_linode_resources" {default = 1}# define provider(s)
provider "linode" {
token = var.linode_token_value
}# create resource(s)
module "public_cloud_resources" {
source = "git::https://github.com/MongoExpUser/Terraform-Created-Resources.git"
}# create outputs
output "linode_sshkeys" {
description = "A list of all created linode_sshkeys"
# the list contains key-value pairs of each linode_sshkey's attributes
value = module.public_cloud_resources.linode_sshkeys
}output "linode_stackscripts" {
description = "A list of all created linode_stackscripts"
# the list contains key-value pairs of each linode_stackscript's attributes
value = module.public_cloud_resources.linode_stackscripts
}output "linode_instance_web_servers" {
description = "A list of all created linode_instances"
# the list contains key-value pairs of each linode_instance's attributes
value = module.public_cloud_resources.linode_instance_web_servers
}```
2) Then, execute the module from the base file (base.tf) in the current working directory (CWD) by typing the following commands at the prompt (assuming running via ```bash``` with ```sudo``` access):
```bash
#1) run init
sudo terraform init
#2) run terraform plan
sudo TF_VAR_linode_token_value="linode-token-value" terraform plan
#3) run terraform apply
sudo TF_VAR_linode_token_value="linode-token-value" terraform apply
```# License
Copyright © 2015 - present. MongoExpUser
Licensed under the MIT license.