Skip to content

dashdevs/terraform-aws-single-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-single-service

Usage

IMPORTANT: We do not pin modules to versions in our examples because of the difficulty of keeping the versions in the documentation in sync with the latest released versions. We highly recommend that in your code you pin the version to the exact version you are using so that your infrastructure remains stable, and update versions in a systematic way so that they do not catch you by surprise.

example for one EC instance:

module "admin_panel_computing" {
  source                    = "dashdevs/single-service/aws"
  name                      = var.name_prefix
  vpc_id                    = var.vpc_id
  ec2_subnets               = var.subnets
  ec2_instance_name_postfix = var.instance_name

  applications_config = {
    core = {
      ports = "80:8080"
    }
  }
}

example for EC2 instance with autoscaling group:

module "computing" {
  source                    = "dashdevs/single-service/aws"
  name                      = var.name_prefix
  vpc_id                    = var.vpc_id
  ec2_subnets               = var.private_subnets
  ec2_instance_type         = var.ec2_instance_type
  target_group_arns         = module.load_balancer.target_group_arns
  ec2_instance_name_postfix = var.instance_name
  create_autoscaling        = true
  ec2_instance_count_max    = 2

  applications_config = {
    core = {
      ports = "80:8080"
      cmd   = null
      env = {
        example_var_name = "example_var_value"
      }
    }
  }
}

Requirements

Name Version
terraform >= 1.9.3
aws >= 5.78

Providers

Name Version
aws >= 5.78

Inputs

Name Description Type Default Required
name Is used to create names for all internal resources of a module. It represents a prefix that will be added to the names of all internal resources to ensure their uniqueness within the module. string n/a yes
vpc_id Identifier of the VPC to which the internal resources will be connected string n/a yes
ec2_subnets List of subnet identifiers to which the internal resources will be connected list(string) n/a yes
ec2_create_eip Used to create Elastic IP and assign to the EC2 instance bool false no
ec2_instance_type EC2 instance type to be used. If create_autoscaling is enabled, this will apply to each instance in the autoscaling group string t2.micro no
ec2_instance_count_min Minimum number of EC2 instances that should be provisioned if create_autoscaling is true number 1 no
ec2_instance_count_max Maximum number of EC2 instances that should be provisioned if create_autoscaling is true number 1 no
ec2_root_storage_size Size of the root volume attached to EC2 instances in gigabytes number 8 no
attach_ecr_based_deployment_policy If true, will attach ecr based deployment policy to EC2 instances bool true no
iam_role_additional_policies List of additional policy for attach to EC2 instances list(string) [] no
create_autoscaling Used to create autoscaling group. If true, will create autoscaling group bool false no
target_group_arns Loadbalancer target group ARN list. Used for attach EC2 instance to loadbalancer, if create_autoscaling is false list(string) [] no
ec2_instance_name_postfix A primary keyword of the instance name. The resulting instance name will consist of name prefix and instance name postfix. string server no
ec2_ingress_ports The list of ports that are allowed for incoming traffic to an EC2 instance list(string) ["80", "22"] no
applications_config Applications configuration map for application name, ports, start command, and environment variables. map(object({ ports = optional(string, null), env = optional(map(string), {}), cmd = optional(string, null) })) {"core": { "ports": "80:8080" }} no

Outputs

Name Description
ec2_instance_role The IAM role identifier assigned to the EC2 instance
ec2_ssh_keypair_value The value of the SSH key pair that will be used for EC2 instances
ec2_security_group_id The security group identifier assigned to the EC2 instance
ec2_instance_id EC2 Instance identifier
ec2_elastic_ip_address Elastic ip address assigned to the EC2 instance

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages