-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ksynth on ec2 instance * Implemented suggestions from review
- Loading branch information
1 parent
e1f3e91
commit 867d757
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Synthetics agent deployment on AWS ec2 instance | ||
|
||
The module creates ec2 instance with provided configuration and deploys `ksynth` agent. | ||
|
||
## Requirements | ||
|
||
| Name | Version | | ||
|--------------|---------| | ||
| terraform | ~> 1.0 | | ||
| aws provider | ~> 4.0 | | ||
| AWS CLI | ~> 4.0 | | ||
|
||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------------------------|--------------------------------------------------|--------------|---------|----------| | ||
| vpc_security_group_ids | List of security groups IDs | list(string) | | true | | ||
| plan_id | Kentik plan ID | string | | true | | ||
| region | Specifies AWS provider region | string | | false | | ||
| key_name | Key name of the Key Pair to use for the instance | string | | false | | ||
| iam_instance_profile | IAM role ID | string | | false | | ||
| subnet_id | Subnet ID | string | | false | | ||
|
||
|
||
## Usage | ||
|
||
```bash | ||
terraform init | ||
terraform apply \ | ||
-var='vpc_security_group_ids=["<vpc-security-group-id>"]' \ | ||
-var='plan_id=<plan-id>' \ | ||
-var='region=<region-name>' \ | ||
-var='key_name=<key-name>' \ | ||
-var='iam_instance_profile=<iam-instance-profile>' \ | ||
-var='subnet_id=<subnet-id>' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
data "aws_ami" "ubuntu" { | ||
most_recent = true | ||
|
||
filter { | ||
name = "name" | ||
# Make sure that given ami is not deprecated. | ||
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] | ||
} | ||
|
||
filter { | ||
name = "virtualization-type" | ||
values = ["hvm"] | ||
} | ||
|
||
owners = ["099720109477"] | ||
} | ||
|
||
resource "aws_instance" "instance" { | ||
ami = data.aws_ami.ubuntu.id | ||
instance_type = "t2.micro" | ||
|
||
iam_instance_profile = var.iam_instance_profile | ||
key_name = var.key_name | ||
vpc_security_group_ids = var.vpc_security_group_ids | ||
subnet_id = var.subnet_id | ||
|
||
user_data = <<EOF | ||
#!/bin/bash | ||
curl -s https://packagecloud.io/install/repositories/kentik/ksynth/script.deb.sh | sudo bash | ||
apt-get install ksynth | ||
echo "KENTIK_COMPANY=${var.plan_id}" >> /etc/default/ksynth | ||
systemctl start ksynth | ||
# Restart agent after setting variables | ||
systemctl stop ksynth && systemctl start ksynth | ||
EOF | ||
|
||
tags = { | ||
Name = "ksynth_agent" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_version = "~> 1.0" | ||
required_providers { | ||
aws = { | ||
version = "~> 4.0" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
variable "key_name" { | ||
description = "Key name of the Key Pair to use for the instance" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "iam_instance_profile" { | ||
description = "IAM role ID" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "subnet_id" { | ||
description = "Subnet ID" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "vpc_security_group_ids" { | ||
description = "List of security groups IDs" | ||
type = list(string) | ||
default = [""] | ||
} | ||
|
||
variable "plan_id" { | ||
description = "Kentik plan ID" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "region" { | ||
description = "Specifies AWS provider region" | ||
type = string | ||
default = "" | ||
} |