Terraform level 4, task 5 - validation failed

Please take a look, thanks.

Could you please include the exact name of the task – “task number” turns out to be ambiguous, and I’m not sure what task you’re actually trying to do.

The task they meant is called “Managing Terraform Code with Symlinks”.

@raymond.baoly any update on this task?

This error I was able to solve . I understand it’s wrong in tasks description. In output kke_sns_topic_name is expected (all output variables should end with _name), but after that this still not managed to resolve dependency part.

Any hints about the meaning of the direct terraform dependency? In the context that the resources are in different modules (as per the task).

I stuck on:

 SSM parameter does not have a visible Terraform graph dependency on SNS.

When checked with summarized graph i see this:

bob@iac-server ~/terraform via 💠 default ➜  terraform graph | grep "parameter.*sns"
  "module.ssm.aws_ssm_parameter.kke" -> "module.sns.aws_sns_topic.kke";

Hi @peshovec

The task asks to create an SSM parameter that stores the ARN of the SNS topic from the SNS module. Please make sure this is done correctly.

Thanks for the hint.

Double-checked, seems ok to me - the ssm parameter name, as well the value. Still fails against the dependency. To be honest in the -type=[plan|apply] graphs the dependency is visible just on the module level. No direct ssm_parameter to any sns.

value:  "arn:aws:sns:us-east-1:000000000000:datacenter-sns-topic"
  arn:  "arn:aws:sns:us-east-1:000000000000:datacenter-sns-topic"
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.

Outputs:

kke_sns_topic_name = "datacenter-sns-topic"
kke_ssm_parameter_name = "datacenter-param"
kke_step_function_name = "datacenter-stepfunction"

bob@iac-server ~/terraform via 💠 default ➜  terraform graph | grep "ssm_parameter.*sns"
  "module.ssm.aws_ssm_parameter.kke" -> "module.sns.aws_sns_topic.kke";

bob@iac-server ~/terraform via 💠 default ➜  terraform state show module.ssm.aws_ssm_parameter.kke | grep name
    name            = "datacenter-param"

bob@iac-server ~/terraform via 💠 default ➜  terraform show -json | jq '.values.root_module.child_modules[].re
sources[].values.value'
null
"arn:aws:sns:us-east-1:000000000000:datacenter-sns-topic"
null
null
null

bob@iac-server ~/terraform via 💠 default ➜  terraform state show module.sns.aws_sns_topic.kke | grep "^ *arn 
*="
    arn                                      = "arn:aws:sns:us-east-1:000000000000:datacenter-sns-topic"
No changes. Your infrastructure matches the configuration.

Still:

 SSM parameter does not have a visible Terraform graph dependency on SNS.

Hi @peshovec

Could you please share your tf files?

The modules ssm main.tf file should be:

resource "aws_ssm_parameter" "this" {
  name  = var.KKE_SSM_PARAM_NAME
  type  = "String"
  value = "arn:aws:sns:us-east-1:000000000000:${var.KKE_SNS_TOPIC_NAME}"
}

Thank you.
i am passing param_value = module.sns.arn to the ssm module. As in my tf files, i gather the arn of the sns topic as output.
Here is part of the ssm module

resource "aws_ssm_parameter" "kke" {
  name  = var.KKE_SSM_PARAM_NAME
  type  = "String"
  value = var.param_value

}

Just tried with the suggestion. Still fails

 SSM parameter does not have a visible Terraform graph dependency on SNS.

ssm module:

bob@iac-server ~/terraform via 💠 default ➜  cat modules/ssm/main.tf 

resource "aws_ssm_parameter" "kke" {
  name  = var.KKE_SSM_PARAM_NAME
  type  = "String"
  value = "arn:aws:sns:us-east-1:000000000000:${var.KKE_SNS_TOPIC_NAME}"

}

graph outputs:

bob@iac-server ~/terraform via 💠 default ✖ terraform graph | grep ssm_parameter
    "module.ssm.aws_ssm_parameter.kke" [label="aws_ssm_parameter.kke"];
  "module.ssm.aws_ssm_parameter.kke" -> "module.sns.aws_sns_topic.kke";
  "module.stepfunctions.aws_iam_role.kke" -> "module.ssm.aws_ssm_parameter.kke";

bob@iac-server ~/terraform via 💠 default ➜  terraform graph -type=plan | grep -i "ssm_parameter.*sns"
                "[root] module.ssm.aws_ssm_parameter.kke (expand)" -> "[root] module.ssm.var.KKE_SNS_TOPIC_NAME (expand)"

Hi @peshovec,

The tfvars should be:

KKE_SNS_TOPIC_NAME       = "datacenter-sns-topic"
KKE_SSM_PARAM_NAME       = "datacenter-param"
KKE_STEP_FUNCTION_NAME   = "datacenter-stepfunction"

And they should be used in the modules directly, like this:

module "sns" {
  source = "./modules/sns"
  KKE_SSM_PARAM_NAME      = var.KKE_SSM_PARAM_NAME
  KKE_SNS_TOPIC_NAME      = var.KKE_SNS_TOPIC_NAME
  KKE_STEP_FUNCTION_NAME  = var.KKE_STEP_FUNCTION_NAME
}

module "ssm" {
  source = "./modules/ssm"
  KKE_SSM_PARAM_NAME      = var.KKE_SSM_PARAM_NAME
  KKE_SNS_TOPIC_NAME      = var.KKE_SNS_TOPIC_NAME
  KKE_STEP_FUNCTION_NAME  = var.KKE_STEP_FUNCTION_NAME
  depends_on = [module.sns]
}

module "stepfunctions" {
  source = "./modules/stepfunctions"
  KKE_SSM_PARAM_NAME      = var.KKE_SSM_PARAM_NAME
  KKE_SNS_TOPIC_NAME      = var.KKE_SNS_TOPIC_NAME
  KKE_STEP_FUNCTION_NAME  = var.KKE_STEP_FUNCTION_NAME
  depends_on = [module.ssm]
}

I noticed you are using KKE_PROJECT, which wasn’t mentioned in the task. Please review the instructions and try again.

Hello!
I’m getting the task failed message and the reason given is,

Step Functions data source does not depend on the SSM parameter.

I tried everything (even avoiding data sources altogether) but the reason never changes.
Can anyone help?

Here is my SSM module:

resource "aws_ssm_parameter" "this" {
  name  = var.KKE_SSM_PARAM_NAME
  type  = "String"
  value = "arn:aws:sns:*:*:${var.KKE_SNS_TOPIC_NAME}"
}

(I already did it with
value = "arn:aws:sns:us-east-1:000000000000:${var.KKE_SNS_TOPIC_NAME}" but the result was same)

I won’t add StepFunctions module main.tf here because its 61 lines and would be nice to know which part I need to give here other than typing a long message