aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/terraform_http_backend_controller.rb19
-rw-r--r--app/views/backends/terraform_aws/show.html.erb7
-rw-r--r--config/routes.rb5
3 files changed, 31 insertions, 0 deletions
diff --git a/app/controllers/terraform_http_backend_controller.rb b/app/controllers/terraform_http_backend_controller.rb
index 4d11961..4587f8a 100644
--- a/app/controllers/terraform_http_backend_controller.rb
+++ b/app/controllers/terraform_http_backend_controller.rb
@@ -46,6 +46,25 @@ class TerraformHttpBackendController < ApplicationController
end
end
+ def show_history
+ @state = TerraformState.where(
+ state_id: state_id
+ ).order(:id).last
+
+ respond_to do |format|
+ format.html do
+ render :show
+ end
+ format.json do
+ if @state.nil?
+ render json: '{}', status: 404
+ else
+ render json: @state.data, status: 200
+ end
+ end
+ end
+ end
+
def show_by_index
@state = TerraformState.where(
state_id: state_id
diff --git a/app/views/backends/terraform_aws/show.html.erb b/app/views/backends/terraform_aws/show.html.erb
index f468567..98034f5 100644
--- a/app/views/backends/terraform_aws/show.html.erb
+++ b/app/views/backends/terraform_aws/show.html.erb
@@ -87,6 +87,13 @@ License along with the GOV.UK Mini Environment Admin. If not, see
Backend down
</div>
<% end %>
+
+ <br>
+ <a href="<%= terraform_http_backend_show_history_path(
+ @backend.terraform_state_id
+ ) %>">
+ View detailed Terraform state information
+ </a>
</div>
</div>
diff --git a/config/routes.rb b/config/routes.rb
index 55aeab5..ce7b624 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -47,6 +47,11 @@ Rails.application.routes.draw do
)
scope :terraform_http_backend do
get(
+ '*state_id/history',
+ to: 'terraform_http_backend#show_history',
+ as: 'terraform_http_backend_show_history'
+ )
+ get(
'*state_id/history/*index',
to: 'terraform_http_backend#show_by_index',
as: 'terraform_http_backend_show_by_index'