Skip to content

CreateResource

Source: src/AWS/CloudControl/CreateResource.ts

Runtime binding for cloudformation:CreateResource.

Provisions any Cloud Control-supported resource from inside a Function — the building block for dynamic, per-tenant provisioning services. The call is asynchronous: poll the returned RequestToken with GetResourceRequestStatus until the operation settles. Because Cloud Control invokes the resource type’s create handler with the caller’s credentials, pass the handler’s underlying permissions via CloudControlBindingOptions.handlerPolicyStatements.

// init — account-level; grant the create handler's permissions too
const createResource = yield* CloudControl.CreateResource({
handlerPolicyStatements: [
{
Effect: "Allow",
Action: ["ssm:PutParameter", "ssm:GetParameters", "ssm:AddTagsToResource"],
Resource: ["*"],
},
],
});
// runtime
const created = yield* createResource({
TypeName: "AWS::SSM::Parameter",
DesiredState: JSON.stringify({
Name: "/tenants/acme/greeting",
Type: "String",
Value: "hello",
}),
});
// poll created.ProgressEvent.RequestToken until SUCCESS