--- tags: 大話AWS雲端架構 --- # Chapter18. CloudFormation ## 18.1 透過設定檔或程式碼,快速建置AWS環境CloudFormation 透過設定檔,可以實現多種AWS架構。 ## 18.2 視覺化設計架構與設定檔 - CloudFormation Designer 透過CloudFormation Designer,以圖像化拖拉的方式設計架構。 ## 18.3 CloudFormation 的核心組件 #### 18.3.1 Template、Stack、Change Set - Template (範本),就是剛剛提到的設定檔。 - Stack (堆疊),就是那些AWS服務。 - Change Set (變更集),則是讓我們能夠有效預覽或追蹤變更過的組件。 #### 18.3.2 服務之間有相依性的話,需要設計DependsOn Template在與現實應用結合時,需注意AWS資源的開啟順序。  #### 18.3.3 服務裡的軟體應用啟動需要時間,可以設置WaitCondition等待軟體應用啟動  ## 18.4 CloudFormation 的收費方式 CloudFormation本身不收費,但開啟出來的服務, 就得按照該服務的付費方式來收費。  ## 18.5 考題解析與思路延伸 #### 18.5.1 [Q] Template 的欄位元素與其意義 [問題描述] A user is planning to use AWS CloudFormation for his automatic deployment requirements. Which of the below mentioned components are required as a part of the template? [答案解析] 在Template設定檔中,Resources屬於必填欄位。 ```json // Resources: 要建立的AWS資源 Resources: HelloBucket: Type: AWS::S3::Bucket // Parameter: 定義使用者用此Template服務時,需要提供的參數,若使用者沒提供參數,則無法建立資源堆疊。 Parameters: KeyName: Description: Name of an existing EC2 KeyPair to enable SSH access into the WordPress web server Type: AWS::EC2::KeyPair::KeyName WordPressUser: Default: admin NoEcho: true Description: The WordPress database admin account user name Type: String MinLength: 1 MaxLength: 16 AllowedPattern: "[a-zA-Z][a-zA-Z0-9]*" WebServerPort: Default: 8888 Description: TCP/IP port for the WordPress web server Type: Number MinValue: 1 MaxValue: 65535 // Mapping: 有些設定對使用者來說較為複雜,我們可以在Template放入一些邏輯,讓使用者可以指定簡單的值 (或者完全不指定),以取得他們希望的結果。 Mappings: RegionMap: us-east-1: AMI: ami-76f0061f us-west-1: AMI: ami-655a0a20 // Outputs: AWS CloudFormation 會在堆疊完成後產生輸出值。可以在AWS CloudFormation主控台的Outputs (輸出)標籤中檢視輸出值。 Outputs: InstallURL: Value: !Join - '' - - 'http://' - !GetAtt - ElasticLoadBalancer - DNSName - /wp-adin/install.php Description: Installation URL of the WordPress website WebsiteURL: Value: !Join - '' - - 'http://' - !GetAtt - ElasticLoadBalancer - DNSName ``` ```json // 整體 Template AWSTemplateFormatVersion: "version date" Description: String Metadata: template metadata Parameters: set of parameters Mappings: set of mappings Conditions: set of conditions Transform: set of transforms Resources: set of resources Outputs: set of outputs ``` ## 18.6 CloudFormation 整體架構圖 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up