diff options
author | Christopher Baines <mail@cbaines.net> | 2018-06-23 23:45:03 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2018-06-23 23:45:03 +0100 |
commit | a60b2982ad8b2a9966fb16aa251ea21a376d711a (patch) | |
tree | 83597ea8546ab8d97dcd30ca67252985e04f7574 /app/models/backends | |
parent | d1f04420a1890705d4c4965d3f3296edee578920 (diff) | |
download | govuk-mini-environment-admin-a60b2982ad8b2a9966fb16aa251ea21a376d711a.tar govuk-mini-environment-admin-a60b2982ad8b2a9966fb16aa251ea21a376d711a.tar.gz |
Switch to using the public AWS domain of the build machine
Rather than the configured domain, as the corresponding SSH key
shouldn't change for the AWS domain (whereas it does for the
configured domain, if the machine changes).
Diffstat (limited to 'app/models/backends')
-rw-r--r-- | app/models/backends/terraform_aws/backend_methods.rb | 10 | ||||
-rw-r--r-- | app/models/backends/terraform_aws/mini_environment_methods.rb | 22 |
2 files changed, 29 insertions, 3 deletions
diff --git a/app/models/backends/terraform_aws/backend_methods.rb b/app/models/backends/terraform_aws/backend_methods.rb index 89509bd..b21c83e 100644 --- a/app/models/backends/terraform_aws/backend_methods.rb +++ b/app/models/backends/terraform_aws/backend_methods.rb @@ -20,8 +20,12 @@ module Backends::TerraformAws::BackendMethods def create_data_snapshot + remote_host = backend_latest_terraform_state.output_value( + 'guix_daemon_public_dns' + ) + GovukGuix::CreateDataSnapshotJob.enqueue( - run_remotely_on_host: "ubuntu@guix-daemon.#{domain}", + run_remotely_on_host: "ubuntu@#{remote_host}", backend_type: self.class.name, backend_id: id ) @@ -101,6 +105,10 @@ module Backends::TerraformAws::BackendMethods ) end + def backend_latest_terraform_state + backend_terraform_states.order(:id).last + end + def status latest_terraform_state = backend_terraform_states.order(:id).last diff --git a/app/models/backends/terraform_aws/mini_environment_methods.rb b/app/models/backends/terraform_aws/mini_environment_methods.rb index e0fe03b..6049829 100644 --- a/app/models/backends/terraform_aws/mini_environment_methods.rb +++ b/app/models/backends/terraform_aws/mini_environment_methods.rb @@ -22,6 +22,14 @@ module Backends::TerraformAws::MiniEnvironmentMethods def build(mini_environment) slug = mini_environment.name.parameterize + remote_build_host = + mini_environment + .backend + .backend_latest_terraform_state + .output_value( + 'guix_daemon_public_dns' + ) + GovukGuix::BuildMiniEnvironment.build( mini_environment.id, services: mini_environment.services.map(&:build_argument_string), @@ -42,7 +50,7 @@ module Backends::TerraformAws::MiniEnvironmentMethods '/var/log/govuk-mini-environment-admin=/var/log' ] }, - run_remotely_on_host: "ubuntu@guix-daemon.#{domain}" + run_remotely_on_host: "ubuntu@#{remote_build_host}" ) end @@ -74,13 +82,23 @@ module Backends::TerraformAws::MiniEnvironmentMethods end end + def terraform_states(mini_environment) + TerraformState.where( + state_id: mini_environment_state_id(mini_environment) + ) + end + def within_terraform_working_directory(mini_environment, &block) TerraformWorkingDirectory.new( - "mini_environment/#{mini_environment.id}", + mini_environment_state_id(mini_environment), 'terraform/aws/mini_environment' ).within_working_directory(&block) end + def mini_environment_state_id(mini_environment) + "mini_environment/#{mini_environment.id}" + end + def signon_url(mini_environment) "https://signon.#{mini_environment.name.parameterize}.#{domain}" end |