Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
*.tfstate*
*.lock.hcl
terraform.auto.tfvars
backend.tf
.sshkey.pem
Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

while getopts i: flag
do
case "${flag}" in
i) PublicIp=${OPTARG};;
esac
done

aws ec2 describe-instances \
--filters "Name=instance-state-name,Values=running" "Name=network-interface.association.public-ip,Values=$PublicIp" \
--query "Reservations[].Instances[].[InstanceId,Tags[?Key=='Name'].Value|[0]]" \
--output table
AgentId=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=network-interface.association.public-ip,Values=$PublicIp" --query "Reservations[].Instances[].[InstanceId,Tags[?Key=='Name'].Value|[0]]" --output json | jq .[0][0] --raw-output)
aws ssm start-session \
--target $AgentId
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
SHELL := /bin/bash

aws: install all

all: init apply ssh output

clean: state destroy

install:
ifeq ($(shell grep "^ID=" /etc/*elease | cut -d "=" -f 2| sed -e 's/^"//' -e 's/"$$//' 2> /dev/null), amzn)
ifeq ($(shell command -v terraform 2> /dev/null),)
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
sudo yum -y install terraform
endif
endif

version:
time terraform version

init:
time terraform init

validate:
time terraform validate

update:
time terraform get -update

plan:
time terraform plan

apply:
time terraform apply -auto-approve

destroy:
time terraform destroy -auto-approve

output:
time terraform output

ssh:
time terraform output SshKey | tail -n +3 | head -n-3 | sed "s/^[ \t]*//" > .sshkey.pem

state:
time terraform state list

connect: connect-app

connect-app:
chmod +x ./CloudShell/connect.sh
./CloudShell/connect.sh -i $$(terraform output -json App | jq -r .eth0.eip.public_ip)

connect-agent1:
chmod +x ./CloudShell/connect.sh
./CloudShell/connect.sh -i $$(terraform output -json Agent1 | jq -r .eth0.eip.public_ip)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IxLoad-on-AWS-1-App-1-Agent-1-VPC-1-Public-Subnet-1-Private-Subnet
# IxLoad-on-AWS-1-App-1-VTA-1-VPC-1-Public-Subnet-1-Private-Subnet

## Description
This deployment creates a topology with a single virtual private cloud having a single public facing subnet and a single private subnet.
Expand All @@ -14,7 +14,7 @@ You **MAY** uncomment one or more lines as needed in these files and replace val
```
terraform init
terraform apply -auto-approve
terraform output SshKey | tail -n +3 | head -n-3 | sed "s/^[ \t]*//" > SshKey.pem
terraform output SshKey | tail -n +3 | head -n-3 | sed "s/^[ \t]*//" > .sshKey.pem
terraform destroy -auto-approve
```
You **MUST** output the SSH key pair associated with the AWS instances.
Expand All @@ -26,4 +26,4 @@ terraform validate
terraform plan
terraform state list
terraform output
```
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
data "aws_caller_identity" "current" {}

data "aws_ec2_instance_type" "Agent" {
instance_type = local.AgentInstanceType
}

data "aws_ec2_instance_type" "App" {
instance_type = local.AppInstanceType
}

data "aws_region" "current" {}

data "aws_availability_zones" "available" {
Expand All @@ -8,4 +16,4 @@ data "aws_availability_zones" "available" {

data "http" "ip" {
url = "https://ifconfig.me/ip"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ locals {
Preamble = "${local.UserLoginTag}-${local.UserProjectTag}-${local.AppTag}"
PrivateSubnetAvailabilityZone = var.PrivateSubnetAvailabilityZone
PublicSubnetAvailabilityZone = var.PublicSubnetAvailabilityZone
Region = data.aws_region.current.name
Region = data.aws_region.current.id
SshKeyAlgorithm = "RSA"
SshKeyName = "${local.Preamble}-ssh-key"
SshKeyRsaBits = "4096"
UserEmailTag = var.UserEmailTag == null ? data.aws_caller_identity.current.user_id : var.UserEmailTag
UserLoginTag = var.UserLoginTag == null ? "terraform" : var.UserLoginTag
UserProjectTag = var.UserProjectTag == null ? random_id.RandomId.id : var.UserProjectTag
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "App" {
source = "git::https://github.com/armdupre/terraform-aws-module-ixload-app.git?ref=11.0.0"
source = "git::https://github.com/Keysight/terraform-aws-module-ixload-app.git?ref=26.0.0"
Eth0SecurityGroupId = module.Vpc.PublicSecurityGroup.id
Eth0SubnetId = module.Vpc.PublicSubnet.id
InstanceType = local.AppInstanceType
Expand All @@ -13,7 +13,7 @@ module "App" {
}

module "Agent1" {
source = "git::https://github.com/armdupre/terraform-aws-module-ixload-agent.git?ref=11.0.0"
source = "git::https://github.com/Keysight/terraform-aws-module-ixload-agent.git?ref=26.0.0"
Eth0SecurityGroupId = module.Vpc.PublicSecurityGroup.id
Eth0SubnetId = module.Vpc.PublicSubnet.id
Eth1SecurityGroupId = module.Vpc.PrivateSecurityGroup.id
Expand Down Expand Up @@ -45,4 +45,4 @@ resource "aws_placement_group" "PlacementGroup" {

resource "random_id" "RandomId" {
byte_length = 4
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
output "Agent1" {
value = {
ami = {
image_id = module.Agent1.Ami.image_id
name = module.Agent1.Ami.name
owner_id = module.Agent1.Ami.owner_id
}
availability_zone = module.Agent1.Instance.availability_zone
eth0 = {
eip = {
public_dns = module.Agent1.Eth0ElasticIp.public_dns
public_ip = module.Agent1.Eth0ElasticIp.public_ip
}
}
id = module.Agent1.Instance.id
instance_type = {
current_generation = data.aws_ec2_instance_type.Agent.current_generation
dedicated_hosts_supported = data.aws_ec2_instance_type.Agent.dedicated_hosts_supported
default_cores = data.aws_ec2_instance_type.Agent.default_cores
default_network_card_index = data.aws_ec2_instance_type.Agent.default_network_card_index
default_threads_per_core = data.aws_ec2_instance_type.Agent.default_threads_per_core
default_vcpus = data.aws_ec2_instance_type.Agent.default_vcpus
ena_srd_supported = data.aws_ec2_instance_type.Agent.ena_srd_supported
ena_support = data.aws_ec2_instance_type.Agent.ena_support
hypervisor = data.aws_ec2_instance_type.Agent.hypervisor
ipv6_supported = data.aws_ec2_instance_type.Agent.ipv6_supported
maximum_ipv4_addresses_per_interface = data.aws_ec2_instance_type.Agent.maximum_ipv4_addresses_per_interface
maximum_ipv6_addresses_per_interface = data.aws_ec2_instance_type.Agent.maximum_ipv6_addresses_per_interface
maximum_network_cards = data.aws_ec2_instance_type.Agent.maximum_network_cards
maximum_network_interfaces = data.aws_ec2_instance_type.Agent.maximum_network_interfaces
memory_size = data.aws_ec2_instance_type.Agent.memory_size
name = module.Agent1.Instance.instance_type
network_performance = data.aws_ec2_instance_type.Agent.network_performance
supported_architectures = data.aws_ec2_instance_type.Agent.supported_architectures
supported_cpu_features = data.aws_ec2_instance_type.Agent.supported_cpu_features
supported_placement_strategies = data.aws_ec2_instance_type.Agent.supported_placement_strategies
}
private_dns = module.Agent1.Instance.private_dns
private_ip = module.Agent1.Instance.private_ip
}
}

output "App" {
value = {
ami = {
image_id = module.App.Ami.image_id
name = module.App.Ami.name
owner_id = module.App.Ami.owner_id
}
availability_zone = module.App.Instance.availability_zone
eth0 = {
eip = {
public_dns = module.App.Eth0ElasticIp.public_dns
public_ip = module.App.Eth0ElasticIp.public_ip
}
}
id = module.App.Instance.id
instance_type = {
current_generation = data.aws_ec2_instance_type.App.current_generation
dedicated_hosts_supported = data.aws_ec2_instance_type.App.dedicated_hosts_supported
default_cores = data.aws_ec2_instance_type.App.default_cores
default_network_card_index = data.aws_ec2_instance_type.App.default_network_card_index
default_threads_per_core = data.aws_ec2_instance_type.App.default_threads_per_core
default_vcpus = data.aws_ec2_instance_type.App.default_vcpus
ena_srd_supported = data.aws_ec2_instance_type.App.ena_srd_supported
ena_support = data.aws_ec2_instance_type.App.ena_support
hypervisor = data.aws_ec2_instance_type.App.hypervisor
ipv6_supported = data.aws_ec2_instance_type.App.ipv6_supported
maximum_ipv4_addresses_per_interface = data.aws_ec2_instance_type.App.maximum_ipv4_addresses_per_interface
maximum_ipv6_addresses_per_interface = data.aws_ec2_instance_type.App.maximum_ipv6_addresses_per_interface
maximum_network_cards = data.aws_ec2_instance_type.App.maximum_network_cards
maximum_network_interfaces = data.aws_ec2_instance_type.App.maximum_network_interfaces
memory_size = data.aws_ec2_instance_type.App.memory_size
name = module.App.Instance.instance_type
network_performance = data.aws_ec2_instance_type.App.network_performance
supported_architectures = data.aws_ec2_instance_type.App.supported_architectures
supported_cpu_features = data.aws_ec2_instance_type.App.supported_cpu_features
supported_placement_strategies = data.aws_ec2_instance_type.App.supported_placement_strategies
}
private_dns = module.App.Instance.private_dns
private_ip = module.App.Instance.private_ip
}
}

output "AvailabilityZones" {
value = {
available = {
names = data.aws_availability_zones.available.names
}
region = data.aws_availability_zones.available.region
}
}

output "SshKey" {
sensitive = true
value = {
private_key_pem = tls_private_key.SshKey.private_key_pem
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# AgentInstanceType = "c5n.xlarge"
# ApiMaxRetries = 1
# AppInstanceType = "t3.xlarge"
# InboundIPv4CidrBlocks = [ "1.1.1.1/32" ]
# InboundIPv4CidrBlocks = [ "0.0.0.0/0" ]
# PrivateSubnetAvailabilityZone = "us-east-1a"
# PublicSubnetAvailabilityZone = "us-east-1a"
# Region = "us-east-1"
# UserEmailTag = "terraform@example.com"
# UserLoginTag = "terraform"
# UserProjectTag = "cloud-ist"
# UserProjectTag = "cloud-ist"
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
variable "AgentInstanceType" {
default = "c5n.xlarge"
description = "Instance type of Agent VM"
type = string
validation {
condition = contains([ "c5n.xlarge", "c5n.2xlarge", "c5n.4xlarge", "c5n.9xlarge", "c5n.18xlarge",
"c6in.xlarge", "c6in.2xlarge", "c6in.4xlarge", "c6in.8xlarge", "c6in.12xlarge", "c6in.16xlarge", "c6in.24xlarge", "c6in.32xlarge" ], var.AgentInstanceType)
error_message = <<EOF
AgentInstanceType must be one of the following types:
c5n.xlarge, c5n.2xlarge, c5n.4xlarge, c5n.9xlarge, c5n.18xlarge,
c6in.xlarge, c6in.2xlarge, c6in.4xlarge, c6in.8xlarge, c6in.12xlarge, c6in.16xlarge, c6in.24xlarge, c6in.32xlarge
EOF
}
}

variable "ApiMaxRetries" {
default = 1
type = number
}

variable "AppInstanceType" {
default = "t3.xlarge"
description = "Instance type of App VM"
type = string
validation {
condition = contains([ "t3.xlarge", "t3.2xlarge" ], var.AppInstanceType)
error_message = <<EOF
AppInstanceType must be one of the following types:
t3.xlarge, t3.2xlarge
EOF
}
}

variable "InboundIPv4CidrBlocks" {
default = [ "0.0.0.0/0" ]
description = "List of IP Addresses /32 or IP CIDR ranges connecting inbound to App"
type = list(string)
}

variable "PrivateSubnetAvailabilityZone" {
default = "us-east-1a"
type = string
}

variable "PublicSubnetAvailabilityZone" {
default = "us-east-1a"
type = string
}

variable "Region" {
default = "us-east-1"
type = string
}

variable "UserEmailTag" {
default = null
description = "Email address tag of user creating the deployment"
type = string
validation {
condition = var.UserEmailTag == null ? true : length(var.UserEmailTag) >= 14
error_message = "UserEmailTag minimum length must be >= 14."
}
}

variable "UserLoginTag" {
default = null
description = "Login ID tag of user creating the deployment"
type = string
validation {
condition = var.UserLoginTag == null ? true : length(var.UserLoginTag) >= 4
error_message = "UserLoginTag minimum length must be >= 4."
}
}

variable "UserProjectTag" {
default = null
description = "Project tag of user creating the deployment"
type = string
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0.0"
version = ">= 6.27.0"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "Vpc" {
source = "git::https://github.com/armdupre/terraform-aws-module-1-vpc-1-public-subnet-1-private-subnet.git?ref=11.0.0"
source = "git::https://github.com/Keysight/terraform-aws-module-1-vpc-1-public-subnet-1-private-subnet.git?ref=26.0.0"
InboundIPv4CidrBlocks = local.InboundIPv4CidrBlocks
PrivateSubnetAvailabilityZone = local.PrivateSubnetAvailabilityZone
PublicSubnetAvailabilityZone = local.PublicSubnetAvailabilityZone
Expand All @@ -17,4 +17,4 @@ resource "aws_security_group_rule" "PublicIngress3389" {
from_port = 3389
to_port = 3389
cidr_blocks = local.InboundIPv4CidrBlocks
}
}
Loading