Terraform Spring Boot Auto-configure

Terraform spring boot auto-configuration.

Лицензия

Лицензия

MIT
Категории

Категории

Spring Boot Контейнер Микросервисы Auto Библиотеки уровня приложения Code Generators config Configuration ORM Данные
Группа

Группа

com.microsoft.terraform
Идентификатор

Идентификатор

terraform-spring-boot-autoconfigure
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Terraform Spring Boot Auto-configure
Terraform spring boot auto-configuration.
Ссылка на сайт

Ссылка на сайт

https://github.com/Microsoft/terraform-spring-boot
Организация-разработчик

Организация-разработчик

Microsoft
Система контроля версий

Система контроля версий

https://github.com/Microsoft/terraform-spring-boot/tree/master

Скачать terraform-spring-boot-autoconfigure

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.microsoft.terraform/terraform-spring-boot-autoconfigure/ -->
<dependency>
    <groupId>com.microsoft.terraform</groupId>
    <artifactId>terraform-spring-boot-autoconfigure</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.microsoft.terraform/terraform-spring-boot-autoconfigure/
implementation 'com.microsoft.terraform:terraform-spring-boot-autoconfigure:1.0.0'
// https://jarcasting.com/artifacts/com.microsoft.terraform/terraform-spring-boot-autoconfigure/
implementation ("com.microsoft.terraform:terraform-spring-boot-autoconfigure:1.0.0")
'com.microsoft.terraform:terraform-spring-boot-autoconfigure:jar:1.0.0'
<dependency org="com.microsoft.terraform" name="terraform-spring-boot-autoconfigure" rev="1.0.0">
  <artifact name="terraform-spring-boot-autoconfigure" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.microsoft.terraform', module='terraform-spring-boot-autoconfigure', version='1.0.0')
)
libraryDependencies += "com.microsoft.terraform" % "terraform-spring-boot-autoconfigure" % "1.0.0"
[com.microsoft.terraform/terraform-spring-boot-autoconfigure "1.0.0"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot jar 1.5.10.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 1.5.10.RELEASE
org.springframework.boot : spring-boot-configuration-processor Необязательный jar 1.5.10.RELEASE
com.microsoft.terraform : terraform-client jar 1.0.0

Модули Проекта

Данный проект не имеет модулей.

Terraform Spring Boot

Introduction

This repository is for Spring Boot Starters of Terraform client.

How to use it

There are two ways you could use this library. One way is to directly use the TerraformClient class which wraps the terraform executable on your local machine; and the other way is to integrate it into a Spring boot application using annotations.

Client library

Simply add the following dependency to your project's pom.xml will enable you to use the TerraformClient class.

<dependency>
    <groupId>com.microsoft.terraform</groupId>
    <artifactId>terraform-client</artifactId>
    <version>1.0.0</version>
</dependency>

And now you are able to provision terraform resources in your Java application. Make sure you have already put a terraform file storage.tf under /some/local/path/ folder; and then use the Java code snippet below to invoke terraform executable operate on the resources defined in storage.tf. In this example, we also assume that you are provisioning Azure specific resource, which means you need to set some Azure related credentials.

TerraformOptions options = new TerraformOptions();
options.setArmSubscriptionId("<Azure Subscription ID>");
options.setArmClientId("<Azure Client ID>");
options.setArmClientSecret("<Azure Client Secret>");
options.setArmTenantId("<Azure Tenant ID>");

try (TerraformClient client = new TerraformClient(options)) {
    client.setOutputListener(System.out::println);
    client.setErrorListener(System.err::println);

    client.setWorkingDirectory("/some/local/path/");
    client.plan().get();
    client.apply().get();
}

Spring boot

Let's still use the terraform file storage.tf under /some/local/path/ folder to provision Azure resources in this example. Rather than create the TerraformClient by ourselves, we let the spring boot framework to wire it for us. First add the following dependency to your pom.xml:

<dependency>
    <groupId>com.microsoft.terraform</groupId>
    <artifactId>terraform-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>

And now let's also introduce the Azure credentials in application.properties:

terraform.armSubscriptionId=<Azure Subscription ID>
terraform.armClientId=<Azure Client ID>
terraform.armClientSecret=<Azure Client Secret>
terraform.armTenantId=<Azure Tenant ID>

The final step is to let the Spring framework wire up everything in your spring boot application:

@SpringBootApplication
public class SpringStarterSampleApp implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(SpringStarterSampleApp.class, args);
    }

    @Autowired
    private TerraformClient terraform;

    @Override
    public void run(String... args) throws Exception {
        try {
            this.terraform.setOutputListener(System.out::println);
            this.terraform.setErrorListener(System.err::println);

            this.terraform.setWorkingDirectory("/some/local/path/");
            this.terraform..plan().get();
            this.terraform.apply().get();
        } finally {
            this.terraform.close();
        }
    }
}

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

com.microsoft.terraform

Microsoft

Open source projects and samples from Microsoft

Версии библиотеки

Версия
1.0.0