Hey all. Can anyone help me with translating terra...
# python
c
Hey all. Can anyone help me with translating terraform/HCL script into python?
p
Usually, translating terraform to pulumi-python is relatively easy. Once you got it, you shouldn’t have any issues with that. You can paste some smaller snippet of the code and we can work on this together. It should give you a great start.
w
@crooked-postman-72907 What cloud are u needing to translate that HCL script to? And what are the high level components your looking to rip in python?
c
thanks for ur message @prehistoric-activity-61023. I did try but maybe it was too much code at once. Do u know if the terraform needs to be running the latest version? Im using a slightly older version as the new version has been causing me issues.
p
I have to say I haven’t used that tool myself 😅. Although, I often manually translate TF files to pulumi (basically because you can find more examples for TF than pulumi at the moment).
c
hey @wooden-barista-808 I am looking to use the python script to create a VPC in AWS. I am able to do it with Terraform/HCL but would like to also build the VPC using python. Is that possible?
p
@crooked-postman-72907 can you paste a fragment of TF code creating VPC? How long is it?
w
+1 👆
But short answer Aaron is yep pretty straight forward
c
pretty long : )
this is about a third of it : ) @prehistoric-activity-61023 @wooden-barista-808
w
sweet - so u could start by creating instances of classes which would be from the native package or classic if needed. But essentially from the base level you could start simple by looking at each resource definition, say vpc in this example.
example of a nat gw
Copy code
example = aws.ec2.NatGateway("example",
    allocation_id=aws_eip["example"]["id"],
    subnet_id=aws_subnet["example"]["id"],
    tags={
        "Name": "gw NAT",
    },
    opts=pulumi.ResourceOptions(depends_on=[aws_internet_gateway["example"]]))
u could translate a resource block from terraform like nat gw to a instance of a class in python as shown above
i can help out more later this afternoon if u need some more but hopefully this gets you started?
c
Thanks so much for this @wooden-barista-808 Really appreciate it. Im not a coder or software engineer so I'm a bit lost exactly with what you mean. So would probably need to do this over a call at some point if thats possible? Does tomorrow morning work for you?