Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem creating an user, an eschedule for they and associate that eschedule to a pre-existing escalation policies. #831

Open
Zarzaparro opened this issue Mar 8, 2024 · 0 comments

Comments

@Zarzaparro
Copy link

I'm trying to create a user, an eschedule for him and associate that eschedule to a pre-existing escalation policies

This is the code that is working:

#New user creation
resource "pagerduty_user" "new_user" {
name = "Pedro Palotes"
email = "palotes@example.com"
role = "user"
}

#New eschedule for him and its association with the new user
resource "pagerduty_schedule" "new_user_schedule" {
name = "Schedule de Pedro Palotes"
description = "Horario de lunes a viernes de 8am a 6pm en horario de España"
time_zone = "Europe/Madrid" # Zona horaria de España

layer configuration

layer {
name = "Layer 1"
start = "08:00:00"
end = "18:00:00"
rotation_virtual_start = "2024-03-11T08:00:00"
rotation_turn_length_seconds = 86400
users = [pagerduty_user.new_user.id]
}
}

But this is the part that does not work:

#Associate that new schedule to varios pre-existence escalation policies
resource "null_resource" "associate_schedule_to_policy" {
triggers = {
schedule_id = data.pagerduty_schedule.new_user_schedule_data.id
name = each.value
for_each = var.escalation_policy_id
}
}

In the variables I have this set:
variable "escalation_policy_id" {
description = "Id de los escalation"
type = set(string)
}

And in the tfvars I have this set:
escalation_policy_id = ["PRDZEJ1", "P99R45N"]

But if I "Terraform plan" I get this error:

A data resource "pagerduty_schedule" "new_user_schedule_data" has not been declared in the root module.

What am I doing wrong?

THanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant