@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
178 lines • 7.33 kB
JavaScript
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.BudgetAction = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides a budget action resource. Budget actions are cost savings controls that run either automatically on your behalf or by using a workflow approval process.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* actions: ["ec2:Describe*"],
* resources: ["*"],
* }],
* });
* const examplePolicy = new aws.iam.Policy("example", {
* name: "example",
* description: "My example policy",
* policy: example.then(example => example.json),
* });
* const current = aws.getPartition({});
* const assumeRole = current.then(current => aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: [`budgets.${current.dnsSuffix}`],
* }],
* actions: ["sts:AssumeRole"],
* }],
* }));
* const exampleRole = new aws.iam.Role("example", {
* name: "example",
* assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
* });
* const exampleBudget = new aws.budgets.Budget("example", {
* name: "example",
* budgetType: "USAGE",
* limitAmount: "10.0",
* limitUnit: "dollars",
* timePeriodStart: "2006-01-02_15:04",
* timeUnit: "MONTHLY",
* });
* const exampleBudgetAction = new aws.budgets.BudgetAction("example", {
* budgetName: exampleBudget.name,
* actionType: "APPLY_IAM_POLICY",
* approvalModel: "AUTOMATIC",
* notificationType: "ACTUAL",
* executionRoleArn: exampleRole.arn,
* actionThreshold: {
* actionThresholdType: "ABSOLUTE_VALUE",
* actionThresholdValue: 100,
* },
* definition: {
* iamActionDefinition: {
* policyArn: examplePolicy.arn,
* roles: [exampleRole.name],
* },
* },
* subscribers: [{
* address: "example@example.example",
* subscriptionType: "EMAIL",
* }],
* tags: {
* Tag1: "Value1",
* Tag2: "Value2",
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import budget actions using `AccountID:ActionID:BudgetName`. For example:
*
* ```sh
* $ pulumi import aws:budgets/budgetAction:BudgetAction myBudget 123456789012:some-id:myBudget
* ```
*/
class BudgetAction extends pulumi.CustomResource {
/**
* Get an existing BudgetAction resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new BudgetAction(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of BudgetAction. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === BudgetAction.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["accountId"] = state?.accountId;
resourceInputs["actionId"] = state?.actionId;
resourceInputs["actionThreshold"] = state?.actionThreshold;
resourceInputs["actionType"] = state?.actionType;
resourceInputs["approvalModel"] = state?.approvalModel;
resourceInputs["arn"] = state?.arn;
resourceInputs["budgetName"] = state?.budgetName;
resourceInputs["definition"] = state?.definition;
resourceInputs["executionRoleArn"] = state?.executionRoleArn;
resourceInputs["notificationType"] = state?.notificationType;
resourceInputs["status"] = state?.status;
resourceInputs["subscribers"] = state?.subscribers;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
}
else {
const args = argsOrState;
if (args?.actionThreshold === undefined && !opts.urn) {
throw new Error("Missing required property 'actionThreshold'");
}
if (args?.actionType === undefined && !opts.urn) {
throw new Error("Missing required property 'actionType'");
}
if (args?.approvalModel === undefined && !opts.urn) {
throw new Error("Missing required property 'approvalModel'");
}
if (args?.budgetName === undefined && !opts.urn) {
throw new Error("Missing required property 'budgetName'");
}
if (args?.definition === undefined && !opts.urn) {
throw new Error("Missing required property 'definition'");
}
if (args?.executionRoleArn === undefined && !opts.urn) {
throw new Error("Missing required property 'executionRoleArn'");
}
if (args?.notificationType === undefined && !opts.urn) {
throw new Error("Missing required property 'notificationType'");
}
if (args?.subscribers === undefined && !opts.urn) {
throw new Error("Missing required property 'subscribers'");
}
resourceInputs["accountId"] = args?.accountId;
resourceInputs["actionThreshold"] = args?.actionThreshold;
resourceInputs["actionType"] = args?.actionType;
resourceInputs["approvalModel"] = args?.approvalModel;
resourceInputs["budgetName"] = args?.budgetName;
resourceInputs["definition"] = args?.definition;
resourceInputs["executionRoleArn"] = args?.executionRoleArn;
resourceInputs["notificationType"] = args?.notificationType;
resourceInputs["subscribers"] = args?.subscribers;
resourceInputs["tags"] = args?.tags;
resourceInputs["actionId"] = undefined /*out*/;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BudgetAction.__pulumiType, name, resourceInputs, opts);
}
}
exports.BudgetAction = BudgetAction;
/** @internal */
BudgetAction.__pulumiType = 'aws:budgets/budgetAction:BudgetAction';
//# sourceMappingURL=budgetAction.js.map
;