Ejemplo n.º 1
0
        public static async void TestConstruction()
        {
            var provider = new Azure()
            {
                ClientId       = "abc",
                ClientSecret   = "123",
                TenantId       = "",
                SubscriptionId = ""
            };

            ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddDebug());
            ILogger        logger        = loggerFactory.CreateLogger <UnitTests>();

            var terraform = new Terraform()
            {
                Path   = new DirectoryInfo(Path.GetTempPath()),
                DryRun = true
            };

            terraform.Providers.Add(provider);
            terraform.Vars.Add("adam2", new List <string>()
            {
                "how", "many", "is", "this"
            });
            var configValues = provider.GetConfig();
            var result       = await terraform.Plan(logger);

            Assert.Equal("terraform plan -var='adam2=[\"how\",\"many\",\"is\",\"this\"]'", result, ignoreWhiteSpaceDifferences: true);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            var provider = new Azure()
            {
                ClientId       = "xxxx",
                ClientSecret   = "xxxx",
                TenantId       = "xxxx",
                SubscriptionId = "xxxx"
            };

            ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
            ILogger        logger        = loggerFactory.CreateLogger <Program>();

            var tf = new Terraform();

            tf.Providers.Add(provider);
            var configValues = provider.GetConfig();

            logger.LogInformation(tf.Init(logger).Result);
            logger.LogInformation(tf.Validate(logger).Result);
            logger.LogInformation(tf.Plan(logger).Result);
            logger.LogInformation(tf.Apply(logger).Result);
            logger.LogInformation(tf.Destroy(logger).Result);
        }