binchoo / PaimonGanyu

여행 비서 페이몬! Genshin Impact AWS workflows & KakaoTalk chatbot skills
https://pf.kakao.com/_mtPFb
GNU General Public License v3.0
7 stars 1 forks source link

[SAM] Review templates and find points to replace with Mappings data #23

Closed binchoo closed 1 year ago

binchoo commented 1 year ago

To-be: The overall goal is to find an elegant way to provide test/prod environments to the PaimonGanyu's architecture.

binchoo commented 1 year ago

Change of Impact

New DNS Hosted Zone

New AWS Account for Test Environment

Third-Level Domain for Test Environment in the New Account

Mappings and Conditions with CFN templates

Parameters:
  Env:
    Type: String
    Default: test
    AllowedValues:
      - test
      - prod
    Description: The enviroment type of this deployment.

  UseALB:
    Type: String
    Default: 'False'
    AllowedValues:
      - 'True'
      - 'False'
    Description: Whether to create an ALB. If Env=prod, an ALB is always created.

Conditions:
  CreateProd: !Equals [!Ref Env, prod]
  CreateALB: !Or [Condition: CreateProd, !Equals [!Ref UseALB, 'True']]

Mappings:
  EnvMap:
    HostedZone:
      prod: paimon.studio.
      test: test.paimon.studio.
    ApiDomain:
      prod: skill.paimon.studio
      test: skill.test.paimon.studio

  RegionEnvMap:
    ap-northeast-2:
      prod: SeoulProd
      test: SeoulTest
    ap-northeast-1:
      prod: TokyoProd
      test: TokyoTest
    CACert:
      SeoulProd: arn:aws:acm:ap-northeast-2:305992497901:certificate/9023abac-1279-4647-8056-ec5be058af4c
      SeoulTest: arn:aws:acm:ap-northeast-2:254804608366:certificate/3ee23337-94cb-47ba-9ce4-b91c0b71ac1b
      TokyoProd: arn:aws:acm:ap-northeast-1:305992497901:certificate/eb2ba354-e8c3-49ec-836d-5003be9c0da7

CFN Template Locations

CFN templates for paimonganyu and paimonganyu-skill stacks exist inside their own gradle project's root directory.

Gradle Tasks Cares SAM Build & Deploy

Gradle tasks take responsibility to execute sam build & deploy CLI commands.