| 1 | import * as appconfig from "@distilled.cloud/aws/appconfig"; |
| 2 | import * as Output from "../../Output.ts"; |
| 3 | import type { Application } from "./Application.ts"; |
| 4 | import { makeAppConfigHttpBinding } from "./BindingHttp.ts"; |
| 5 | import type { ConfigurationProfile } from "./ConfigurationProfile.ts"; |
| 6 | import type { DeploymentStrategy } from "./DeploymentStrategy.ts"; |
| 7 | import type { Environment } from "./Environment.ts"; |
| 8 | import { StartDeployment } from "./StartDeployment.ts"; |
| 9 | |
| 10 | /** |
| 11 | * HTTP implementation of the {@link StartDeployment} binding. Calls |
| 12 | * `appconfig:StartDeployment` with the Lambda's IAM role, scoped to the bound |
| 13 | * application, environment, configuration profile, and deployment strategy. |
| 14 | */ |
| 15 | export const StartDeploymentHttp = makeAppConfigHttpBinding(StartDeployment, { |
| 16 | operation: appconfig.startDeployment, |
| 17 | spec: ( |
| 18 | application: Application, |
| 19 | environment: Environment, |
| 20 | configurationProfile: ConfigurationProfile, |
| 21 | deploymentStrategy: DeploymentStrategy, |
| 22 | ) => ({ |
| 23 | identifiers: { |
| 24 | ApplicationId: application.applicationId, |
| 25 | EnvironmentId: environment.environmentId, |
| 26 | ConfigurationProfileId: configurationProfile.configurationProfileId, |
| 27 | DeploymentStrategyId: deploymentStrategy.deploymentStrategyId, |
| 28 | }, |
| 29 | iam: ({ region, accountId }) => ({ |
| 30 | actions: ["appconfig:StartDeployment"], |
| 31 | resources: [ |
| 32 | Output.interpolate`arn:aws:appconfig:${region}:${accountId}:application/${application.applicationId}`, |
| 33 | Output.interpolate`arn:aws:appconfig:${region}:${accountId}:application/${application.applicationId}/environment/${environment.environmentId}`, |
| 34 | Output.interpolate`arn:aws:appconfig:${region}:${accountId}:application/${application.applicationId}/configurationprofile/${configurationProfile.configurationProfileId}`, |
| 35 | Output.interpolate`arn:aws:appconfig:${region}:${accountId}:deploymentstrategy/${deploymentStrategy.deploymentStrategyId}`, |
| 36 | ], |
| 37 | }), |
| 38 | }), |
| 39 | }); |