@@ -3,6 +3,12 @@ resource "random_string" "stack_name_suffix" {
33 special = false
44}
55
6+ data "spacelift_current_stack" "this" {}
7+
8+ data "spacelift_stack" "current_stack" {
9+ stack_id = data. spacelift_current_stack . this . id
10+ }
11+
612# Terraform stack
713resource "spacelift_stack" "terraform-ansible-workflow-terraform" {
814 branch = data. spacelift_stack . current_stack . branch
@@ -44,11 +50,6 @@ resource "spacelift_aws_role" "terraform-stack" {
4450 role_arn = var. aws_role
4551}
4652
47- resource "spacelift_policy_attachment" "ignore-outside-project-root-terraform" {
48- policy_id = spacelift_policy. ignore-outside-project-root . id
49- stack_id = spacelift_stack. terraform-ansible-workflow-terraform . id
50- }
51-
5253resource "spacelift_policy_attachment" "trigger-dependent-stacks-terraform" {
5354 policy_id = spacelift_policy. trigger-dependent-stacks . id
5455 stack_id = spacelift_stack. terraform-ansible-workflow-terraform . id
@@ -59,7 +60,6 @@ resource "spacelift_stack_destructor" "terraform-stack" {
5960 spacelift_environment_variable . ansible_context_id ,
6061 spacelift_environment_variable . aws_region ,
6162 spacelift_aws_role . terraform-stack ,
62- spacelift_policy_attachment . ignore-outside-project-root-terraform ,
6363 spacelift_policy_attachment . trigger-dependent-stacks-terraform ,
6464 ]
6565
@@ -102,28 +102,11 @@ resource "spacelift_aws_role" "ansible-stack" {
102102 role_arn = var. aws_role
103103}
104104
105- resource "spacelift_policy_attachment" "ignore-outside-project-root-ansible" {
106- policy_id = spacelift_policy. ignore-outside-project-root . id
107- stack_id = spacelift_stack. terraform-ansible-workflow-ansible . id
108- }
109-
110105resource "spacelift_policy_attachment" "warn-on-unreachable-hosts-ansible" {
111106 policy_id = spacelift_policy. warn-on-unreachable-hosts . id
112107 stack_id = spacelift_stack. terraform-ansible-workflow-ansible . id
113108}
114109
115- # Ignore outside of project root for current stack
116- data "spacelift_current_stack" "this" {}
117-
118- data "spacelift_stack" "current_stack" {
119- stack_id = data. spacelift_current_stack . this . id
120- }
121-
122- resource "spacelift_policy_attachment" "ignore-outside-project-root-this" {
123- policy_id = spacelift_policy. ignore-outside-project-root . id
124- stack_id = data. spacelift_current_stack . this . id
125- }
126-
127110# Trigger a run in terraform stack
128111
129112resource "spacelift_run" "this" {
@@ -132,6 +115,5 @@ resource "spacelift_run" "this" {
132115 depends_on = [
133116 spacelift_environment_variable . ansible_context_id ,
134117 spacelift_aws_role . ansible-stack ,
135- spacelift_policy_attachment . ignore-outside-project-root-ansible ,
136118 ]
137119}
0 commit comments