· 6 years ago · Jul 10, 2019, 11:22 AM
1provider "aws" {
2 access_key = "AKIA3EMAIJZISOZAWFPP"
3 secret_key = "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"
4 region = "eu-north-1"
5}
6resource "aws_instance" "new" {
7 # ...instance configuration...
8 ami = "ami-4bd45f35"
9 availability_zone = "eu-north-1b"
10 ebs_optimized = true
11 instance_type = "t3.medium"
12 monitoring = false
13 key_name = "new"
14 subnet_id = "subnet-5af3f122"
15 vpc_security_group_ids = ["sg-0a4f03bc2ee1fda8b"]
16 associate_public_ip_address = true
17 private_ip = "172.16.1.101"
18 source_dest_check = true
19
20 root_block_device {
21 volume_type = "gp2"
22 volume_size = 8
23 delete_on_termination = true
24 }
25}
26resource "aws_iam_user" "lb" {
27 name = "loadbalancer"
28 path = "/system/"
29
30 tags = {
31 tag-key = "tag-value"
32 }
33}
34
35resource "aws_iam_access_key" "lb" {
36 user = "${aws_iam_user.lb.name}"
37}
38
39resource "aws_iam_user_policy" "lb_ro" {
40 name = "test"
41 user = "${aws_iam_user.lb.name}"
42
43 policy = <<EOF
44{
45 "Version": "2012-10-17",
46 "Statement": [
47 {
48 "Action": [
49 "ec2:Describe*"
50 ],
51 "Effect": "Allow",
52 "Resource": "*"
53 }
54 ]
55}
56EOF
57}