Skip to content

Commit 8064e73

Browse files
committed
misc/kea_mysql.rb: read endpoint from tfstate
1 parent 20eefd4 commit 8064e73

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

misc/kea_mysql.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
#!/usr/bin/env ruby
2+
require 'bundler/inline'
3+
gemfile do
4+
source 'https://rubygems.org'
5+
gem 'aws-sdk-rds'
6+
gem 'aws-sdk-s3'
7+
gem 'rexml'
8+
end
29
require 'thread'
310
require 'socket'
4-
require 'aws-sdk-rds'
511
require 'open-uri'
6-
EP = 'kea.cluster-ckdkc1trpp8e.ap-northeast-1.rds.amazonaws.com'
12+
require 'json'
13+
14+
EP = begin
15+
Aws::S3::Client.new(region: 'ap-northeast-1').get_object(bucket: 'rk-infra', key: 'terraform/nw-dhcp.tfstate')
16+
.then { JSON.parse(_1.body.read) }
17+
.then { _1.fetch('outputs').fetch('rds_endpoint').fetch('value') }
18+
end
719
BASTION = 'bastion.rubykaigi.net'
820
USER = 'rk'
921
CA_BUNDLE = 'https://truststore.pki.rds.amazonaws.com/ap-northeast-1/ap-northeast-1-bundle.pem'

tf/dhcp/rds.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ resource "aws_route53_record" "kea1-db-apne1-rubykaigi-net" {
7878
"${aws_rds_cluster.kea.endpoint}.",
7979
]
8080
}
81+
82+
output "rds_endpoint" {
83+
value = aws_rds_cluster.kea.endpoint
84+
}

0 commit comments

Comments
 (0)