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

Can't parse public_dns as list<string> #5

Closed
omerlewitz opened this issue Aug 3, 2021 · 0 comments
Closed

Can't parse public_dns as list<string> #5

omerlewitz opened this issue Aug 3, 2021 · 0 comments

Comments

@omerlewitz
Copy link

Hi Samuel,

I was wondering if you have any clue how to handle dynamic attributes, and in general all of the non-primitive types.

I have attached three files as shown below.

The main issue is within the GetTerraformType which parse the types.

With that being said I was able to catch list<string> which was inserted by a simple text string without any interpolation whatsoever. For instance in the .tf file machines = ["omer", "omer ,"etc"].

resource "aws_instance" "ubuntu_machine" {
  ami                         = "ami-09e67e426f25ce0d7"
  instance_type               = "t2.micro"
  key_name                    = "raven"
  associate_public_ip_address = true

  vpc_security_group_ids = [
    aws_security_group.ravendb_access.id
  ]
  

  tags = {
    Name = "RavenDB Instance"
  }
}


resource "ravendb_cluster" "my_cluster" {
    depends_on = [aws_instance.ubuntu_machine]
    
    machines = [flatten(aws_instance.ubuntu_machine.public_dns)]
   
}

output "ravendb_cluster_ubuntu_machine_id" {
  value = aws_instance.ubuntu_machine.public_dns
}
namespace SampleProvider
{
    [MessagePackObject]
    public class ResourceRavenCluster
    {
        [Key("id")]
        [Computed]
        [Description("Unique ID for this resource.")]
        [MessagePackFormatter(typeof(ComputedValueFormatter))]
        public string Id { get; set; }
        
        [Key("machines")]
        [Description("Machine Public Ips")]
        public dynamic Machines { get; set; }    
    }
        private static string GetTerraformType(Type t)
        {
            if (t == typeof(string))
            {
                return "\"string\"";
            }
            
            if (t == typeof(int))
            {
                return "\"number\"";
            }
            
            if (t == typeof(List<string>))
            {
                 return "[\"list\",\"string\"]";
            }
            
            if (t == typeof(List<object>))
            {
                return "dynamic";
            }
            if (t == typeof(List<object>))
            {
                return "[\"list\",\"dynamic\"]";
            }

            throw new NotSupportedException();
        }
    }
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