aboutsummaryrefslogtreecommitdiff
path: root/publishing/publishing.tf
blob: 8d487a350ce7436a151367bf385e0cafb139b8e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
variable "ami_key_pair_name" {}
variable "route53_zone_id" { type = "string" }
variable "route53_zone_name" { type = "string" }

provider "aws" {
    region = "eu-west-1"
    skip_region_validation = true
}

terraform {
  backend "s3" {
    bucket = "linaro-terraform-state"
    key = "lss/production/publishing.tfstate"
    region = "us-east-1"
    skip_region_validation = true
  }
}

data "terraform_remote_state" "vpc" {
  backend = "s3"
  config{
    bucket = "linaro-terraform-state"
    key = "lss/production/ctt-vpc.tfstate"
    region = "us-east-1"
    skip_region_validation = true
  }
}


data "aws_ami" "ubuntu" {
    most_recent = true

    filter {
        name   = "name"
        values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"]
    }

    owners = ["099720109477"] # Official Canonical ID
}

resource "aws_instance" "publishing-ie" {
    ami           = "ami-0286372f78291e588" # "${data.aws_ami.ubuntu.id}"
    instance_type = "t3.large"
    ebs_optimized = "true"
    subnet_id = "${data.terraform_remote_state.vpc.ctt-subnet-id}"
    vpc_security_group_ids = [ "${data.terraform_remote_state.vpc.ctt-sg-id}",
                        "${data.terraform_remote_state.vpc.ctt-web-sg-id}" ]
    key_name = "${var.ami_key_pair_name}"
    tags = {
        Name = "publishing-ie"
    }
}


resource "aws_eip" "publishing-ie-ip" {
  instance = "${aws_instance.publishing-ie.id}"
  vpc      = true
}

resource "aws_route53_record" "publishing-ie-dns" {
  zone_id = "${var.route53_zone_id}"
  name = "publishing-ie"
  type = "A"
  ttl     = "60"
  records = ["${aws_eip.publishing-ie-ip.public_ip}"]
}

resource "aws_route53_record" "releases-ap-dns" {
  zone_id = "${var.route53_zone_id}"
  name = "releases-ap"
  type = "CNAME"
  ttl     = "60"
  records = ["ec2-13-228-101-204.ap-southeast-1.compute.amazonaws.com"]
}

resource "aws_route53_record" "releases-eu-lat" {
  zone_id = "${var.route53_zone_id}"
  name = "releases"
  type = "CNAME"
  ttl     = "60"
  records = ["${aws_route53_record.publishing-ie-dns.name}.${var.route53_zone_name}"]
}

resource "aws_route53_record" "snapshots-dns" {
  zone_id = "${var.route53_zone_id}"
  name = "snapshots"
  type = "CNAME"
  ttl     = "60"
  records = ["ec2-34-252-32-115.eu-west-1.compute.amazonaws.com"]
}

resource "aws_route53_record" "testdata-dns" {
  zone_id = "${var.route53_zone_id}"
  name = "testdata"
  type = "CNAME"
  ttl     = "60"
  records = ["${aws_route53_record.publishing-ie-dns.name}.${var.route53_zone_name}"]
}

resource "aws_route53_record" "snapshots-staging-dns" {
  zone_id = "${var.route53_zone_id}"
  name = "snapshots-staging"
  type = "CNAME"
  ttl     = "60"
  records = ["${aws_route53_record.publishing-ie-dns.name}.${var.route53_zone_name}"]
}