|
| 1 | +data"aws_acm_certificate""stubbornjava" { |
| 2 | +domain="stubbornjava.com" |
| 3 | +statuses=["ISSUED"] |
| 4 | +} |
| 5 | + |
| 6 | +data"aws_acm_certificate""wildcard_stubbornjava" { |
| 7 | +domain="*.stubbornjava.com" |
| 8 | +statuses=["ISSUED"] |
| 9 | +} |
| 10 | + |
| 11 | +resource"aws_alb""StubbornJavaLB" { |
| 12 | +name="StubbornJavaLB" |
| 13 | +internal=false |
| 14 | +load_balancer_type="application" |
| 15 | +security_groups=["sg-d10c37ac"] |
| 16 | +subnets=["${data.aws_subnet_ids.public.ids}"] |
| 17 | +ip_address_type="ipv4" |
| 18 | + |
| 19 | +enable_deletion_protection=true |
| 20 | +} |
| 21 | + |
| 22 | +resource"aws_lb_target_group""StubbornJavaWeb" { |
| 23 | +name="StubbornJavaWeb" |
| 24 | +port=8080 |
| 25 | +protocol="HTTP" |
| 26 | +vpc_id="${data.aws_vpc.selected.id}" |
| 27 | + |
| 28 | +health_check { |
| 29 | +interval=30 |
| 30 | +path="/" |
| 31 | +port="traffic-port" |
| 32 | +protocol="HTTP" |
| 33 | +timeout=5 |
| 34 | +healthy_threshold=5 |
| 35 | +unhealthy_threshold=2 |
| 36 | +matcher=200 |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +resource"aws_lb_listener""sj_https" { |
| 41 | +load_balancer_arn="${aws_alb.StubbornJavaLB.arn}" |
| 42 | +port="443" |
| 43 | +protocol="HTTPS" |
| 44 | +ssl_policy="ELBSecurityPolicy-2015-05" |
| 45 | +certificate_arn="${data.aws_acm_certificate.stubbornjava.arn}" |
| 46 | + |
| 47 | +default_action { |
| 48 | +target_group_arn="${aws_lb_target_group.StubbornJavaWeb.arn}" |
| 49 | +type="forward" |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +resource"aws_lb_listener""sj_http" { |
| 54 | +load_balancer_arn="${aws_alb.StubbornJavaLB.arn}" |
| 55 | +port="80" |
| 56 | +protocol="HTTP" |
| 57 | + |
| 58 | +default_action { |
| 59 | +target_group_arn="${aws_lb_target_group.StubbornJavaWeb.arn}" |
| 60 | +type="forward" |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +resource"aws_lb_target_group_attachment""StubbornJavaWeb" { |
| 65 | +target_group_arn="${aws_lb_target_group.StubbornJavaWeb.arn}" |
| 66 | +target_id="i-0839a0bbe4cd3cf40" |
| 67 | +port=8080 |
| 68 | +} |
| 69 | + |
| 70 | +resource"aws_alb""InternalAppsLB" { |
| 71 | +name="InternalAppsLB" |
| 72 | +internal=false |
| 73 | +load_balancer_type="application" |
| 74 | +security_groups=["sg-3d320448"] |
| 75 | +subnets=["${data.aws_subnet_ids.public.ids}"] |
| 76 | +ip_address_type="ipv4" |
| 77 | + |
| 78 | +enable_deletion_protection=true |
| 79 | +} |
| 80 | + |
| 81 | +resource"aws_lb_target_group""InternalApps80" { |
| 82 | +name="InternalApps80" |
| 83 | +port=80 |
| 84 | +protocol="HTTP" |
| 85 | +vpc_id="vpc-e130ee84" |
| 86 | + |
| 87 | +health_check { |
| 88 | +interval=30 |
| 89 | +path="/" |
| 90 | +port="traffic-port" |
| 91 | +protocol="HTTP" |
| 92 | +timeout=5 |
| 93 | +healthy_threshold=5 |
| 94 | +unhealthy_threshold=2 |
| 95 | +matcher=301 |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +resource"aws_lb_target_group""Jenkins8080" { |
| 100 | +name="Jenkins8080" |
| 101 | +port=8080 |
| 102 | +protocol="HTTP" |
| 103 | +vpc_id="vpc-e130ee84" |
| 104 | + |
| 105 | +health_check { |
| 106 | +interval=30 |
| 107 | +path="/" |
| 108 | +port="traffic-port" |
| 109 | +protocol="HTTP" |
| 110 | +timeout=5 |
| 111 | +healthy_threshold=5 |
| 112 | +unhealthy_threshold=2 |
| 113 | +matcher=403 |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | +resource"aws_lb_listener""internal_https" { |
| 118 | +load_balancer_arn="${aws_alb.InternalAppsLB.arn}" |
| 119 | +port="443" |
| 120 | +protocol="HTTPS" |
| 121 | +ssl_policy="ELBSecurityPolicy-2015-05" |
| 122 | +certificate_arn="${data.aws_acm_certificate.wildcard_stubbornjava.arn}" |
| 123 | + |
| 124 | +default_action { |
| 125 | +target_group_arn="${aws_lb_target_group.Jenkins8080.arn}" |
| 126 | +type="forward" |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +resource"aws_lb_listener""internal_http" { |
| 131 | +load_balancer_arn="${aws_alb.InternalAppsLB.arn}" |
| 132 | +port="80" |
| 133 | +protocol="HTTP" |
| 134 | + |
| 135 | +default_action { |
| 136 | +target_group_arn="${aws_lb_target_group.InternalApps80.arn}" |
| 137 | +type="forward" |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +resource"aws_lb_target_group_attachment""InternalApps80" { |
| 142 | +target_group_arn="${aws_lb_target_group.InternalApps80.arn}" |
| 143 | +target_id="${aws_instance.ci.id}" |
| 144 | +port=80 |
| 145 | +} |
| 146 | + |
| 147 | +resource"aws_lb_target_group_attachment""Jenkins8080" { |
| 148 | +target_group_arn="${aws_lb_target_group.Jenkins8080.arn}" |
| 149 | +target_id="${aws_instance.ci.id}" |
| 150 | +port=8080 |
| 151 | +} |
| 152 | + |
| 153 | +resource"aws_lb_listener_rule""jenkins_http" { |
| 154 | +listener_arn="${aws_lb_listener.internal_http.arn}" |
| 155 | +priority=99 |
| 156 | + |
| 157 | +action { |
| 158 | +type="forward" |
| 159 | +target_group_arn="${aws_lb_target_group.InternalApps80.arn}" |
| 160 | + } |
| 161 | + |
| 162 | +condition { |
| 163 | +field="host-header" |
| 164 | +values=["jenkins.stubbornjava.com"] |
| 165 | + } |
| 166 | +} |
| 167 | + |
| 168 | +resource"aws_lb_listener_rule""jenkins_https" { |
| 169 | +listener_arn="${aws_lb_listener.internal_https.arn}" |
| 170 | +priority=99 |
| 171 | + |
| 172 | +action { |
| 173 | +type="forward" |
| 174 | +target_group_arn="${aws_lb_target_group.Jenkins8080.arn}" |
| 175 | + } |
| 176 | + |
| 177 | +condition { |
| 178 | +field="host-header" |
| 179 | +values=["jenkins.stubbornjava.com"] |
| 180 | + } |
| 181 | +} |