Skip to content

Instantly share code, notes, and snippets.

View 100daysofdevops's full-sized avatar
🎯
Focusing

100daysofdevops

🎯
Focusing
View GitHub Profile
{
"builders": [{
"type": "amazon-ebs",
"region": "us-west-2",
"source_ami": "ami-01ed306a12b7d1c96",
"instance_type": "t2.micro",
"ssh_username": "centos",
"ami_name": "centos-packer-example-1.0"
}]
}
{
"post-processors": [
[
"compress",
{ "type": "upload", "endpoint": "http://example.com" }
]
]
}
"provisioners": [
{
"type": "shell",
"script": "./example.sh"
}
]
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp}}"
}]
data "aws_availability_zones" "all" {}
resource "aws_autoscaling_group" "test-asg" {
launch_configuration = "${aws_launch_configuration.asg-config.id}"
availability_zones = ["${data.aws_availability_zones.all.names}"]
target_group_arns = ["${var.target_group_arn}"]
health_check_type = "ELB"
min_size = "1"
max_size = "2"
tag {
key = "Name"
resource "aws_launch_configuration" "asg-config" {
image_id = "${var.image_id}"
instance_type = "${var.instance_type}"
security_groups = ["${aws_security_group.asg-sg.id}"]
lifecycle {
create_before_destroy = true
}
}
# Modifying an EBS Volume
$ aws ec2 modify-volume --volume-type io1 --iops 100 --size 10 --volume-id vol-Xyz123456
{
"VolumeModification": {
"TargetSize": 10,
"TargetVolumeType": "io1",
"ModificationState": "modifying",
"VolumeId": "vol-Xyz123456",
"TargetIops": 100,
"StartTime": "2019-03-02T17:29:53.000Z",
provider "aws" {
region = "us-west-2"
}
resource "aws_lb" "my-test-lb" {
name = "my-test-lb"
internal = false
load_balancer_type = "application"
ip_address_type = "ipv4"
subnets = ["${var.subnet_id1}", "${var.subnet_id2}"]
resource "aws_security_group" "alb-sg" {
name = "my-alb-sg"
vpc_id = "${var.vpc_id}"
}
resource "aws_security_group_rule" "http_allow" {
from_port = 80
protocol = "tcp"
security_group_id = "${aws_security_group.alb-sg.id}"
to_port = 80
resource "aws_lb_target_group_attachment" "my-tg-attachment1" {
target_group_arn = "${aws_lb_target_group.my-alb-tg.arn}"
target_id = "${var.instance_id1}"
port = 80
}
resource "aws_lb_target_group_attachment" "my-tg-attachment2" {
target_group_arn = "${aws_lb_target_group.my-alb-tg.arn}"
target_id = "${var.instance_id2}"
port = 80