terraformhandler.py
def terraformDump(self):
        """Dumps out two configuration files.  Iterates through Provider, Resource, and Variable sections.
           Within the Resource section, specifically drop VPC, Subnet, Instance configuration.
        """
        # making the MAIN.TF file equivalent
        targetRegion = self.targetRegion

        fp = open(self.mainConfigFileName, "w")

        tfcode = self.providerOutput(region=targetRegion)
        fp.write(tfcode)

        # for VPCS
        vpcForDefaultSubnet = ""
        tfcode = ""
        for data in self.resourceDictList["vpc"]:
            if data["IsDefault"]:
                vpcForDefaultSubnet = data["VpcId"]
            else:
                tfcode += self.resourceOutput(
                    "vpc", data["VpcId"], data["VpcId"], data["Tags"], data["VpcId"]
                )
        fp.write(tfcode)

        # for SUBNETS
        tfcode = ""
        for data in self.resourceDictList["subnet"]:
            if data["VpcId"] == vpcForDefaultSubnet:
                continue
            tfcode += self.resourceOutput(
                "subnet", data["VpcId"], data["SubnetId"], data["Tags"], data["VpcId"]
            )
        fp.write(tfcode)

        # for INSTANCES
        tfcode = ""
        for data in self.resourceDictList["instance"]:
            # check for tags, and set with a default or different output?
            # hack for now
            if "Tags" not in data:
                data["Tags"] = ""

            if self.amiOverride:
                # tfcode = self.resourceInstanceOutput(data.instanceid, data.instancetype, self.amiOverride, data.subnetid, data.tags)
                tfcode = self.resourceInstanceOutput(
                    data["InstanceId"],
                    data["InstanceType"],
                    self.amiOverride,
                    data["SubnetId"],
                    data["Tags"],
                )
            else:
                logger.debug(data)
                tfcode = self.resourceInstanceOutput(
                    data["InstanceId"],
                    data["InstanceType"],
                    data["ImageId"],
                    data["SubnetId"],
                    data["Tags"],
                )
            fp.write(tfcode)
        fp.close()

        ### VARIABLES.TF
        fp = open(self.variableFileName, "w")

        tfcode = ""
        resourceTypeList = ["vpc", "subnet"]

        # unclear if instances need variables
        # duplicate variables being outputed here.

        # for resourceType in resourceTypeList:
        for data in self.resourceDictList["vpc"]:
            tagValue = ""
            if "Tags" in data:
                tagValue = data["Tags"]
            tfcode = self.variableOutput(
                "vpc", data["VpcId"], data["CidrBlock"], tagValue
            )
            fp.write(tfcode)

        for data in self.resourceDictList["subnet"]:
            tagValue = ""
            if "Tags" in data:
                tagValue = data["Tags"]
            tfcode = self.variableOutput(
                "subnet", data["SubnetId"], data["CidrBlock"], tagValue
            )
            fp.write(tfcode)

        fp.close()
Dumps out two configuration files.  Iterates through Provider, Resource, and Variable sections.
           Within the Resource section, specifically drop VPC, Subnet, Instance configuration.
        
Dumps out two configuration files.  Iterates through Provider, Resource, and Variable sections.
Within the Resource section, specifically drop VPC, Subnet, Instance configuration.
Dumps out two configuration files . Iterates through Provider Resource and Variable sections . Within the Resource section specifically drop VPC Subnet Instance configuration .
def terraformDump(self):
        targetRegion = self.targetRegion
        fp = open(self.mainConfigFileName, "w")
        tfcode = self.providerOutput(region=targetRegion)
        fp.write(tfcode)
        vpcForDefaultSubnet = ""
        tfcode = ""
        for data in self.resourceDictList["vpc"]:
            if data["IsDefault"]:
                vpcForDefaultSubnet = data["VpcId"]
            else:
                tfcode += self.resourceOutput(
                    "vpc", data["VpcId"], data["VpcId"], data["Tags"], data["VpcId"]
                )
        fp.write(tfcode)
        tfcode = ""
        for data in self.resourceDictList["subnet"]:
            if data["VpcId"] == vpcForDefaultSubnet:
                continue
            tfcode += self.resourceOutput(
                "subnet", data["VpcId"], data["SubnetId"], data["Tags"], data["VpcId"]
            )
        fp.write(tfcode)
        tfcode = ""
        for data in self.resourceDictList["instance"]:
            if "Tags" not in data:
                data["Tags"] = ""
            if self.amiOverride:
                tfcode = self.resourceInstanceOutput(
                    data["InstanceId"],
                    data["InstanceType"],
                    self.amiOverride,
                    data["SubnetId"],
                    data["Tags"],
                )
            else:
                logger.debug(data)
                tfcode = self.resourceInstanceOutput(
                    data["InstanceId"],
                    data["InstanceType"],
                    data["ImageId"],
                    data["SubnetId"],
                    data["Tags"],
                )
            fp.write(tfcode)
        fp.close()
        fp = open(self.variableFileName, "w")
        tfcode = ""
        resourceTypeList = ["vpc", "subnet"]
        for data in self.resourceDictList["vpc"]:
            tagValue = ""
            if "Tags" in data:
                tagValue = data["Tags"]
            tfcode = self.variableOutput(
                "vpc", data["VpcId"], data["CidrBlock"], tagValue
            )
            fp.write(tfcode)
        for data in self.resourceDictList["subnet"]:
            tagValue = ""
            if "Tags" in data:
                tagValue = data["Tags"]
            tfcode = self.variableOutput(
                "subnet", data["SubnetId"], data["CidrBlock"], tagValue
            )
            fp.write(tfcode)
        fp.close()
def terraformDump ( self ) : targetRegion = self . targetRegion fp = open ( self . mainConfigFileName , "w" ) tfcode = self . providerOutput ( region = targetRegion ) fp . write ( tfcode ) vpcForDefaultSubnet = "" tfcode = "" for data in self . resourceDictList [ "vpc" ] : if data [ "IsDefault" ] : vpcForDefaultSubnet = data [ "VpcId" ] else : tfcode += self . resourceOutput ( "vpc" , data [ "VpcId" ] , data [ "VpcId" ] , data [ "Tags" ] , data [ "VpcId" ] ) fp . write ( tfcode ) tfcode = "" for data in self . resourceDictList [ "subnet" ] : if data [ "VpcId" ] == vpcForDefaultSubnet : continue tfcode += self . resourceOutput ( "subnet" , data [ "VpcId" ] , data [ "SubnetId" ] , data [ "Tags" ] , data [ "VpcId" ] ) fp . write ( tfcode ) tfcode = "" for data in self . resourceDictList [ "instance" ] : if "Tags" not in data : data [ "Tags" ] = "" if self . amiOverride : tfcode = self . resourceInstanceOutput ( data [ "InstanceId" ] , data [ "InstanceType" ] , self . amiOverride , data [ "SubnetId" ] , data [ "Tags" ] , ) else : logger . debug ( data ) tfcode = self . resourceInstanceOutput ( data [ "InstanceId" ] , data [ "InstanceType" ] , data [ "ImageId" ] , data [ "SubnetId" ] , data [ "Tags" ] , ) fp . write ( tfcode ) fp . close ( ) fp = open ( self . variableFileName , "w" ) tfcode = "" resourceTypeList = [ "vpc" , "subnet" ] for data in self . resourceDictList [ "vpc" ] : tagValue = "" if "Tags" in data : tagValue = data [ "Tags" ] tfcode = self . variableOutput ( "vpc" , data [ "VpcId" ] , data [ "CidrBlock" ] , tagValue ) fp . write ( tfcode ) for data in self . resourceDictList [ "subnet" ] : tagValue = "" if "Tags" in data : tagValue = data [ "Tags" ] tfcode = self . variableOutput ( "subnet" , data [ "SubnetId" ] , data [ "CidrBlock" ] , tagValue ) fp . write ( tfcode ) fp . close ( )
Dumps out two configuration files.
Dumps out two configuration files .
"""Dumps out two configuration files.  Iterates through Provider, Resource, and Variable sections.
           Within the Resource section, specifically drop VPC, Subnet, Instance configuration.
        """ # making the MAIN.TF file equivalent # for VPCS # for SUBNETS # for INSTANCES # check for tags, and set with a default or different output? # hack for now # tfcode = self.resourceInstanceOutput(data.instanceid, data.instancetype, self.amiOverride, data.subnetid, data.tags) ### VARIABLES.TF # unclear if instances need variables # duplicate variables being outputed here. # for resourceType in resourceTypeList:
self