'backend'에 해당되는 글 3건

  1. 2020.07.31 [Terraform] S3 Backend 사용.
  2. 2020.06.18 [Spring] Spring Cloud Config 다중 Backend 사용 시...
  3. 2020.03.26 [AWS] Spring Cloud Config S3 Backend 사용하기

[Terraform] S3 Backend 사용.

Cloud&Container/IaC 2020. 7. 31. 14:21

공식 문서는 아래 참고 하세요.

https://www.terraform.io/docs/backends/types/s3.html

 

terraform {
  backend "s3" {
    bucket = "버킷이름"
    key    = "폴더/파일"
    region = "ap-northeast-2"
  }
}
  • s3 backend 를 사용하기 위해서 먼저 s3 bucket 을 생성 합니다.
  • key 부분은 미리 생성해 놓지 않아도 terraform 실행을 하시면 생성이 됩니다.
  • 만약 bucket 을 만들어 놓지 않고 실행을 하게 되면 아래와 같은 에러가 발생 합니다.
Error refreshing state: BucketRegionError: incorrect region, 
the bucket is not in 'ap-northeast-2' region at endpoint ''
	status code: 301, request id: , host id:
  • bucket 을 생성 하고  $ terraform init 을 해도 같은 에러가 계속 발생 합니다.
  • 이 경우 .terraform 폴더를 삭제 하고 다시 시도 하시면 정상적으로 동작 합니다.

Terraform 기본 명령어)

$ terraform init

$ terraform plan

$ terraform apply

$ terraform destroy

.aws 에 aws configure 를 통한 설정이 되어 있어야 합니다.

 

 

:

[Spring] Spring Cloud Config 다중 Backend 사용 시...

ITWeb/개발일반 2020. 6. 18. 10:41

Spring Cloud Config 를 이용해서 다중 Backend 를 구성 할 수 있습니다.

그러나 order 옵션이 저는 제대로 동작 하지 않아서 실행 시 사용해야 하는 Backend 에 대한 profile 로 관리하기로 했습니다.

 

동시에 두 개의 Backend 를 사용 하는 것도 가능 한데 이게 같은 설정 파일이 양쪽에 다 존재 할 때 order 에 맞춰서 설정 정보를 가져 와야 하는데 이상하게도 git 에 있는 설정을 먼저 가져 와서 목적에 맞게 사용을 할 수 없었습니다.

 

spring:
  application:
    name: config-server
  profiles:
    active: awss3, git
  cloud:
    config:
      server:
        awss3:
          region: ap-northeast-2
          bucket: ${BUCKET-NAME}
          order: 1
        git:
          uri: https://git/config-repo.git
          skipSslValidation: true
          username: xxxxx
          password: xxxxx
          clone-on-start: true
          order: 2

저렇게 설정 하고 했었는데 잘 못된 부분이 있다면 댓글 좀 달아 주세요. :)

 

profile을 실행 시점에 awss3 나 git 으로 설정해서 사용 하도록 마무리 했습니다.

:

[AWS] Spring Cloud Config S3 Backend 사용하기

Cloud&Container/AWS 2020. 3. 26. 10:57

Spring Cloud Config Server 설정)

 

[S3 설정]
- S3 버킷 생성
- 접근권한 부여

[ConfigApplication.java]

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


[build.gradle]

compile 'com.amazonaws:aws-java-sdk-s3'


[application.yml]

server:
port: 8888

spring:
  profiles:
    active: awss3
  cloud:
    config:
      server:
        awss3:
          region: ap-northeast-2
          bucket: s3config


[Config Server 접근 URL]

http://localhost:8888/${S3-FILE-NAME}/${PROFILE-NAME}

- 생성한 버킷 하위로 설정 파일 목록이 존재 해야 합니다.
- ${S3-FILE-NAME} 는 생성한 Bucket 아래 만든 설정 파일명 입니다.
- backoffice
- ${PROFILE-NAME} 은 설정 파일에 대한 프로필명 입니다.
- app1, app2

예제)
Config Server URL : 
http://localhost:8888/backoffice/app1

S3 :
megatoidiscons3config/backoffice-app1.yml
or
megatoidiscons3config/backoffice-app1.properties


[backoffice-app1.yml]

project.app1="backoffice-app1"


[backoffice-app2.yml]

project.app2="backoffice-app2"

 

Spring Cloud Config Client 설정)

[application.yml]

spring:
  cloud:
    config:
      name: backoffice
      uri: http://localhost:8888
      profile: app1,app2


[HelloController.java]

@RestController
public class HelloController {

  @Value ("${project.app1}")
  String projectApp1;

  @Value ("${project.app2}")
  String projectApp2;

  @RequestMapping("/app1")
  public String helloApp1() {
    return projectApp1;
  }

  @RequestMapping("/app2")
  public String helloApp2() {
    return projectApp2;
  }
}

 

git 사용 하는 건 문서들이 많이 나와 있어서 s3 로 정리해 봤습니다.

: