You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: reading IAM Instance Profile (BURoleForEC2test): couldn't find resource
with module.test_ec2_1.module.ec2_instance.data.aws_iam_instance_profile.given[0],
on .terraform/modules/test_ec2_1.ec2_instance/main.tf line 84, in data "aws_iam_instance_profile" "given":
84: data "aws_iam_instance_profile" "given" {
Environment
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Describe the Bug
unable to pass instance profile dynamically from other module as the below data block is looking for existing resource in aws.
data "aws_iam_instance_profile" "given" {
count = local.enabled && var.instance_profile_enabled && var.instance_profile != "" ? 1 : 0
name = var.instance_profile
}
Expected Behavior
Code should facilitate to pass instance profile externally from other module also, however data block looks for already existing resource in aws
data block is not required as it is not allowing to pass the instance profile dynamically from another module
Steps to Reproduce
module "ec2_instance" {
source = "cloudposse/ec2-instance/aws"
version = "1.6.1"
namespace = var.namespace
stage = var.stage
name = var.name
enabled = var.enabled
ami = var.ami
instance_type = var.instance_type
ssh_key_pair = var.ssh_key_pair
vpc_id = var.vpc_id
subnet = var.subnet
availability_zone = var.availability_zone
security_group_enabled = false
security_groups = var.security_groups
user_data = var.user_data
user_data_base64 = var.user_data_base64
user_data_replace_on_change = var.user_data_replace_on_change
delete_on_termination = var.delete_on_termination
disable_api_stop = var.disable_api_stop
disable_api_termination = var.disable_api_termination
monitoring = var.monitoring
secondary_private_ips = var.external_network_interface_enabled ? null : var.secondary_private_ips
instance_profile_enabled = var.instance_profile_enabled
instance_profile = local.instance_profile
}
locals {
instance_profile = var.instance_profile_enabled && var.custom_instance_profile != "" ? var.custom_instance_profile : (var.instance_profile_enabled ? "BURoleForEC2" : "")
instance_profile_count = var.enabled && var.instance_profile_enabled && var.custom_instance_profile == "" ? 1 : 0
}
Screenshots
Error: reading IAM Instance Profile (BURoleForEC2test): couldn't find resource
with module.test_ec2_1.module.ec2_instance.data.aws_iam_instance_profile.given[0],
on .terraform/modules/test_ec2_1.ec2_instance/main.tf line 84, in data "aws_iam_instance_profile" "given":
84: data "aws_iam_instance_profile" "given" {
Environment
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: