將環境元件新增至藍圖 - Amazon CodeCatalyst

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

將環境元件新增至藍圖

自訂藍圖精靈會從透過精靈公開的Options介面動態產生。Blueprints 支援從公開類型產生使用者介面 (UI) 元件。

匯入 Amazon CodeCatalyst 藍圖環境元件

在您的blueprint.ts檔案中,新增下列項目:

import {...} from '@amazon-codecatalyst/codecatalyst-environments'

建立開發環境

下列範例示範如何將應用程式部署至雲端:

export interface Options extends ParentOptions { ... myNewEnvironment: EnvironmentDefinition{ thisIsMyFirstAccountConnection: AccountConnection{ thisIsARole: Role['lambda', 's3', 'dynamo']; }; }; }

介面會產生 UI 元件,要求具有單一帳戶連線 (myNewEnvironment) 的新環境 ()thisIsMyFirstAccountConnection。 帳戶連線 (thisIsARole) 上的角色也會與 產生,['lambda', 's3', 'dynamo']作為最低必要角色功能。並非所有使用者都有帳戶連線,因此您應該檢查使用者未連線帳戶或未將帳戶與角色連線的情況。角色也可以使用 加上註釋@inlinePolicies。如需詳細資訊,請參閱@inlinePolicy ./path/to/policy/file.json

環境元件需要 nameenvironmentType。下列程式碼是所需的最低預設形狀:

{ ... "myNewEnvironment": { "name": "myProductionEnvironment", "environmentType": "PRODUCTION" }, }

然後 UI 元件會提示您輸入各種欄位。當您填寫欄位時,藍圖會得到完全展開的形狀。將完整的模擬檔包含在defaults.json檔案中,以用於測試和開發目的,對您很有幫助。

環境清單

指定 類型的陣列EnvironmentDefinition會在精靈 UI 中產生環境清單。

export interface Options extends ParentOptions { ... /** @showName readOnly */ myEnvironments: EnvironmentDefinition<{ thisIsMyFirstAccountConnection: AccountConnection<{ thisIsARole: Role<['lambda', 's3', 'dynamo']>; }>; }>[]; }

下列範例顯示環境清單的預設值:

{ ... "myEnvironments": [ { "name": "myProductionEnvironment", "environmentType": "PRODUCTION" }, { "name": "myDevelopmentEnvironment", "environmentType": "DEVELOPMENT" }, ] }

模擬介面範例

簡單模擬界面

{ ... "thisIsMyEnvironment": { "name": "myProductionEnvironment", "environmentType": "PRODUCTION", "thisIsMySecondAccountConnection": { "id": "12345678910", "name": "my-account-connection-name", "secondAdminRole": { "arn": "arn:aws:iam::12345678910:role/ConnectedQuokkaRole", "name": "ConnectedQuokkaRole", "capabilities": [ "lambda", "s3", "dynamo" ] } } } }

複雜的模擬介面

export interface Options extends ParentOptions { /** * The name of an environment * @displayName This is a Environment Name * @collapsed */ thisIsMyEnvironment: EnvironmentDefinition{ /** * comments about the account that is being deployed into * @displayName This account connection has an overriden name * @collapsed */ thisIsMyFirstAccountConnection: AccountConnection{ /** * Blah blah some information about the role that I expect * e.g. here's a copy-pastable policy: [to a link] * @displayName This role has an overriden name */ adminRole: Role['admin', 'lambda', 's3', 'cloudfront']; /** * Blah blah some information about the second role that I expect * e.g. here's a copy-pastable policy: [to a link] */ lambdaRole: Role['lambda', 's3']; }; /** * comments about the account that is being deployed into */ thisIsMySecondAccountConnection: AccountConnection{ /** * Blah blah some information about the role that I expect * e.g. here's a copy-pastable policy: [to a link] */ secondAdminRole: Role['admin', 'lambda', 's3', 'cloudfront']; /** * Blah blah some information about the second role that I expect * e.g. here's a copy-pastable policy: [to a link] */ secondLambdaRole: Role['lambda', 's3']; }; }; }

完整模擬界面

{ ... "thisIsMyEnvironment": { "name": "my-production-environment", "environmentType": "PRODUCTION", "thisIsMySecondAccountConnection": { "id": "12345678910", "name": "my-connected-account", "secondAdminRole": { "name": "LambdaQuokkaRole", "arn": "arn:aws:iam::12345678910:role/LambdaQuokkaRole", "capabilities": [ "admin", "lambda", "s3", "cloudfront" ] }, "secondLambdaRole": { "name": "LambdaQuokkaRole", "arn": "arn:aws:iam::12345678910:role/LambdaQuokkaRole", "capabilities": [ "lambda", "s3" ] } }, "thisIsMyFirstAccountConnection": { "id": "12345678910", "name": "my-connected-account", "adminRole": { "name": "LambdaQuokkaRole", "arn": "arn:aws:iam::12345678910:role/LambdaQuokkaRole", "capabilities": [ "admin", "lambda", "s3", "cloudfront" ] }, "lambdaRole": { "name": "LambdaQuokkaRole", "arn": "arn:aws:iam::12345678910:role/LambdaQuokkaRole", "capabilities": [ "lambda", "s3" ] } } }, }