How to use the CloudFormation function from aws-sdk
Find comprehensive JavaScript aws-sdk.CloudFormation code examples handpicked from public code repositorys.
AWS SDK CloudFormation is a service provided by Amazon Web Services (AWS) that enables developers to manage AWS infrastructure resources programmatically using templates, in order to create, update, or delete cloud environments in a more efficient and automated manner.
31 32 33 34 35 36 37 38 39 40
cli.flags.region = cli.flags.region || cli.flags.r || 'us-east-1'; if (!cli.flags.stackName) cli.showHelp(); const sqs = new AWS.SQS({ region: cli.flags.region }); const cfn = new AWS.CloudFormation({ region: cli.flags.region }); const actions = { purge, writeOut, replay, triage }; const queues = await findQueues(cfn, cli.flags);
How does aws-sdk.CloudFormation work?
AWS SDK CloudFormation
works by providing a set of APIs and tools that allow developers to manage AWS infrastructure resources programmatically using templates.
When using AWS SDK CloudFormation
, developers can create a template file that specifies the desired AWS resources, including their properties and dependencies, and then use the CloudFormation APIs to create, update, or delete a stack that represents the cloud environment based on the template.
The CloudFormation service then takes care of provisioning and configuring the specified resources, ensuring that they are properly created, configured, and interconnected. The service also provides features for monitoring and logging the status of the resources and handling errors or failures that may occur during the stack creation process.
In addition to the CloudFormation service itself, the AWS SDK for JavaScript provides a set of client-side APIs for working with CloudFormation stacks and templates. These APIs allow developers to create, update, or delete stacks, inspect stack resources and events, and validate and parse template files.
By using AWS SDK CloudFormation
, developers can automate the creation and management of AWS infrastructure resources, making it easier to deploy and scale cloud environments in a more efficient and repeatable way.
1 2 3 4 5 6 7 8 9
const AWS = require('aws-sdk'); const CodeDeploy = new AWS.CodeDeploy(); const Lambda = new AWS.Lambda(); const CloudWatch = new AWS.CloudWatch(); const CloudFormation = new AWS.CloudFormation(); const DynamoDB = new AWS.DynamoDB(); const S3 = new AWS.S3(); const ConfigService = new AWS.ConfigService();
11 12 13 14 15 16 17 18 19 20 21
} } class CloudFormationDeployer { constructor(region, bucketManager, deploymentBucket) { this.cloudFormationClient = new CloudFormation({ region }); this.bucketManager = bucketManager; this.deploymentBucket = deploymentBucket; }
+ 11 other calls in file
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
const AWS = require("aws-sdk"); // create a new CloudFormation client object const cloudFormation = new AWS.CloudFormation({ region: "us-west-2" }); // define a CloudFormation stack template const stackTemplate = ` { "Resources": { "MyBucket": { "Type": "AWS::S3::Bucket", "Properties": { "BucketName": "my-bucket" } } } } `; // create a new CloudFormation stack from the template cloudFormation.createStack( { StackName: "my-stack", TemplateBody: stackTemplate, }, (err, data) => { if (err) { console.error(err); } else { console.log(data); } } );
In this example, we're using the AWS SDK for JavaScript with CloudFormation to create a new stack of AWS resources. We first create a new AWS.CloudFormation object with the desired region, allowing us to interact with the CloudFormation service using the JavaScript SDK. We then define a JSON string that represents a CloudFormation stack template, which specifies the resources we want to create. In this case, we're creating an S3 bucket with the name "my-bucket". Finally, we call the createStack method on the cloudFormation object, passing in the stack name and the template body. This creates a new CloudFormation stack with the specified resources and properties. When we run this code, it will create a new stack named "my-stack" with a single S3 bucket resource named "my-bucket". The response from the createStack method will contain information about the stack creation process, including the ID and status of the new stack.
GitHub: superluminar-io/mavm
41 42 43 44 45 46 47 48 49 50 51 52
accessKeyId: assumedRoleCreds.Credentials.AccessKeyId, secretAccessKey: assumedRoleCreds.Credentials.SecretAccessKey, sessionToken: assumedRoleCreds.Credentials.SessionToken, }; const cloudformation = new AWS.CloudFormation({ credentials: roleCreds }); // this is a smoke test if the cross account role has been set up const cfnResult = await cloudformation.listStacks().promise(); }
+ 32 other calls in file
11 12 13 14 15 16 17 18 19 20
this.awsProvider = this.serverless.providers.aws; const credentials = this.awsProvider.getCredentials(); credentials.region = this.awsProvider.getRegion(); this.apigatewayV2 = new this.serverless.providers.aws.sdk.ApiGatewayV2(credentials); this.route53 = new this.awsProvider.sdk.Route53(credentials); this.cfn = new AWS.CloudFormation(credentials); if(this.config.edgeLambda) { this.lambda = new this.awsProvider.sdk.Lambda({ ...credentials, region: 'us-east-1'
GitHub: mytaptrack/samtsc
29 30 31 32 33 34 35 36 37 38
const lastForwardSlash = path.lastIndexOf('/'); this.stackDir = lastForwardSlash > 0? path.slice(0, lastForwardSlash) : "."; this.events = new EventEmitter(); this.ssm = new aws.SSM({ region: samconfig.region }); this.cf = new aws.CloudFormation({ region: samconfig.region }); } cleanup() { this.compiledDirectories && Object.values(this.compiledDirectories).forEach(x => x.cleanup());
+ 28 other calls in file
14 15 16 17 18 19 20 21 22 23
"Cannot find env var AWS_SAM_STACK_NAME.\n" + "Please setup this environment variable with the stack name where we are running integration tests." ); } const client = new AWS.CloudFormation(); try { await client .describeStacks({ StackName: stackName,
+ 7 other calls in file
85 86 87 88 89 90 91 92 93 94
? template : path.join(GITHUB_WORKSPACE, template); templateBody = fs.readFileSync(templateFilePath, "utf8"); } const region = core.getInput("region", { required: true }); const cfn = new aws.CloudFormation({ ...clientConfiguration, region }); const cfnHelper = new CfnHelper_1.CfnHelper(cfn); // CloudFormation Stack Parameter for the creation or update const params = { StackName: stackName,
+ 19 other calls in file
28 29 30 31 32 33 34 35 36 37
const aws = __importStar(require("aws-sdk")); const fs = __importStar(require("fs")); // import { deployStack, getStackOutputs } from "./deploy"; const Utils_1 = require("./Utils"); const CfnHelper_1 = require("./CfnHelper"); // export type CreateChangeSetInput = aws.CloudFormation.Types.CreateChangeSetInput // export type InputNoFailOnEmptyChanges = "1" | "0" // export type InputCapabilities = // | "CAPABILITY_IAM" // | "CAPABILITY_NAMED_IAM"
+ 121 other calls in file
3 4 5 6 7 8 9 10 11 12 13 14 15
const AWS = require('aws-sdk'); const { prop, indexBy } = require('ramda'); const PROJECT_NAME = process.env.PROJECT_NAME; const cloudFormation = new AWS.CloudFormation(); const iam = new AWS.IAM(); function prefixGlobalResourceName(name) { return `${PROJECT_NAME}-${name}`;
aws-sdk.S3 is the most popular function in aws-sdk (7245 examples)