View a markdown version of this page

CloudFormation Language Server - AWS CloudFormation

CloudFormation Language Server

The AWS CloudFormation Language Server helps you write CloudFormation templates in an editor. As you type, it suggests resource types and properties, shows documentation, finds errors, lets you jump to definitions, and offers fixes for some problems. It uses the Language Server Protocol (LSP), which lets the server work with different editors. Starting and using the Language Server for these local authoring features doesn't require an AWS account or AWS credentials.

The AWS Toolkit integrations also use the Language Server for online workflows that call AWS services. These workflows can browse resources and stacks. They can also run service-side template validation, deploy templates, show change set differences, and monitor stack events. These online workflows are the only features that require an active AWS account and valid AWS credentials.

IDEs integrating with the CloudFormation Language Server

AWS provides off-the-shelf integration with the CloudFormation Language Server through the AWS Toolkit for the following IDEs:

The following IDEs also support the CloudFormation Language Server:

  • Kiro

  • Cursor

  • Most VS Code forks and distributions

For Visual Studio Code and JetBrains IDEs, install the AWS Toolkit. The Toolkit includes and starts the Language Server, so you don't need to download the server separately.

For another editor that supports LSP, download the file for your computer from the latest release on GitHub, extract it, and configure your editor to run the following command:

node /path/to/install-location/cfn-lsp-server-standalone.js --stdio

For supported Node.js versions, available downloads, file verification, and setup examples for different editors, see the standalone installation guide.

Getting started

The following steps show how to use the Language Server through the AWS Toolkit for Visual Studio Code and JetBrains IDEs. For another editor, follow its setup example in the standalone installation guide.

Prerequisites

Before you begin, make sure that:

  • You are using a supported IDE on macOS, Windows, or Linux.

  • For Visual Studio Code or a JetBrains IDE, install or update the AWS Toolkit.

  • For another editor, install a supported Node.js version and download the Language Server file for your computer. The standalone installation guide lists the supported versions and files.

You don't need an AWS account or AWS credentials to start the Language Server or use its local authoring and template-checking features. Configure valid AWS credentials in the Toolkit only when you use online workflows that browse resources or stacks, call the CloudFormation service, or deploy a template.

Step 1: Install or upgrade the AWS Toolkit

Install or update to the latest version of the AWS Toolkit from your IDE's extension or plugin manager, then restart your IDE.

After installation, the AWS Toolkit automatically enables CloudFormation IDE support. When you first install or upgrade the AWS Toolkit with the CloudFormation Language Server, you are prompted to grant permission for AWS to collect anonymous usage data. This data helps AWS improve the CloudFormation Language Server and enhances the authoring experience. No sensitive information is collected and AWS does not record or store template content, resource configurations, or any identifiable customer data. You can change your telemetry preferences at any time from the IDE settings. Restart the IDE for the changes to take effect. The usage data collected focuses only on feature interactions and performance metrics. These insights help AWS identify and prioritize improvements such as faster validation, enhanced autocomplete, and better error diagnostics.

Step 2: Access CloudFormation in the AWS Toolkit

After installing the AWS Toolkit, open the CloudFormation panel in your IDE. In VS Code, open the AWS Toolkit panel from the activity bar and choose CLOUDFORMATION. In JetBrains IDEs, open the AWS Toolkit tool window from the side bar and select the CloudFormation tab.

The CloudFormation panel contains the following sections:

  • Region: Displays the current AWS Region. In VS Code, you can change it by selecting the Region name or by using the AWS CloudFormation: Select Region command from the command palette. In JetBrains IDEs, the Region is configured through the AWS Toolkit connection settings.

  • Stacks: Displays a paginated list of CloudFormation stacks in your account. Expand a stack to view its Change Sets node, which lists the change sets associated with that stack. Use the View Stack Detail action to open the stack detail view, which displays the stack overview, events, outputs, and resources.

  • Resources: After you add a resource type, the panel displays the AWS resources of that type in your account. You can view, refresh, copy, or import them into your template.

In JetBrains IDEs, the toolbar above the tree provides quick access to common actions including Validate and Deploy, Rerun Validate and Deploy, Add Resource Type, and Refresh. Actions are also available through right-click context menus on tree nodes.

Step 3: Validate, test, and refine your template

As you write your CloudFormation template, the CloudFormation Language Server runs in the background and provides local authoring assistance without AWS credentials:

  • Code completion: Suggests resource types, parameters, and properties based on CloudFormation schemas.

  • Extract to parameter: When your cursor is on a literal value in a template (for example, a string like t2.micro), the IDE offers a refactoring action to extract the value into the Parameters section and replace the literal with a !Ref to the new parameter. If the same literal value appears in multiple places, you can choose to extract all occurrences at once.

The Toolkit also provides an online workflow for adding existing AWS resources to your template. This workflow requires valid AWS credentials and uses the AWS Cloud Control API (CCAPI) to retrieve a resource's live configuration and properties, helping you clone or reuse existing infrastructure within your template.

To add resources to your template

  • Add a resource type: In the AWS Toolkit CloudFormation panel, under Resources, add a resource type to browse. In VS Code, click the Add + icon or use the AWS CloudFormation: Add Resource Types command from the command palette. In JetBrains, click the Add Resource Type button in the toolbar or right-click the Resources node.

  • Search for a resource type: In the search dialog, type the AWS resource type you want to add. Example:

    • AWS::S3::Bucket

    • AWS::Lambda::Function

  • Browse resources: Under the Resources section, a paginated list of detected AWS resources in your account is displayed. If you have many resources, only the first page is shown. Use the navigation controls to move through additional pages and view all available resources.

  • Choose the resource you want to include in your template.

  • You can insert a resource into your template in two ways, depending on your goal:

    • Clone an existing resource: Create a new resource in your template using the live configuration and properties of an existing AWS resource.

    • Import an existing resource: Insert the actual resource into your stack by adding it to your template using its live state.

Tips

  • You can refresh the Resources section at any time to view the latest list of resources available in your account or Region.

  • If you are importing resources, do not add a resource that already belongs to an existing CloudFormation stack in the same account.

  • To confirm if a resource is already managed by CloudFormation, use the information action next to the resource. In VS Code, click the i icon. In JetBrains IDEs, right-click the resource and choose Get Stack Management Info.

In VS Code, run the AWS CloudFormation: Add Related Resources by Type command from the command palette. Select a resource type from those already defined in your template. The IDE lists resource types that the selected type can reference through its properties. For example, if you select an AWS::EC2::Instance, the IDE may suggest AWS::EC2::SecurityGroup or AWS::EC2::Subnet. Select one or more related resource types, and then choose whether to create new resource definitions or import existing resources. This feature is currently not supported in JetBrains IDEs.

Static validation

The CloudFormation Language Server provides built-in static validation powered by CloudFormation Linter and CloudFormation Guard. These checks run locally behind the scenes and don't require AWS credentials. They help you identify syntax errors, compliance gaps, and best-practice issues before deployment.

Static validation overview

You will see two types of real-time static validations in the IDE:

  • CloudFormation Linter (cfn-lint): Validates your template against CloudFormation resource specifications and schema rules.

  • Guard (cfn-guard): Validates your template against compliance rules and organizational policy packs.

CloudFormation Linter (cfn-lint)

The CloudFormation Linter is integrated into the IDE to automatically check your template syntax and structure as you type.

  • Schema validation: Detects syntax and schema errors to ensure your templates conform to CloudFormation resource schema.

  • Error highlighting: Displays inline markers under issues, representing deployment blockers or warnings.

  • Hover help: When you hover over an error, the IDE shows the diagnostic message associated with that issue. If a quick fix is available, it is also offered.

Guard integration

Guard validates your templates against rule sets that define compliance and security policies. The IDE runs Guard validations in real time through the CloudFormation Language Server, giving you immediate feedback while you author templates.

  • Default rule packs: The IDE includes a pre-registered set of Guard rules focused on foundational best practices for resource security and configuration hygiene. To learn more, see the guard rule registry.

  • Adding rule packs: To add or modify rule sets, open your IDE settings and navigate to the Guard configuration section to select or upload additional Guard rule packs.

Tips: Understanding diagnostic indicators

  • Blue indicators: Best practice hints or optimization recommendations.

  • Yellow indicators: Warnings for non-blocking issues (for example, missing tags or parameters).

  • Red indicators: Deployment blockers such as invalid property names, missing required fields, or schema mismatches.

Step 4: Navigate through the template

The IDE provides a structured, hierarchical view of your CloudFormation template, organized into sections such as Parameters, Resources, Outputs, and Mappings, showing each resource type and logical ID. This makes it easy to quickly locate and navigate to specific resources or parameters within large templates. In VS Code, the Outline panel in the Explorer sidebar displays this structure. In JetBrains IDEs, open the Structure tool window to view the template structure for the currently open file.

You can use Go to Definition for intrinsic functions such as GetAtt and Ref, allowing you to jump directly to the referenced resource or parameter in your template. This helps you trace dependencies, understand resource relationships, and make edits more efficiently.

Step 5: Validate and deploy

Validate and Deploy is an online workflow that calls the CloudFormation service and requires valid AWS credentials. When you are ready to deploy your template, use this feature to create a change set. The IDE validates your template, and if no blocking errors are found, it proceeds to create a drift-aware change set. The IDE then shows a diff view so you can review all proposed changes before executing the change set.

In VS Code, open the command palette and run AWS CloudFormation: Validate and Deploy. The command palette guides you through selecting a template, stack name, parameters, capabilities, and other deployment options step by step. In JetBrains IDEs, use the Validate and Deploy toolbar button, right-click a template file in the editor, or right-click a stack in the tree. JetBrains presents a wizard dialog where you configure all deployment options including template selection, stack name, parameters, capabilities, tags, and advanced options.

How validation works

The IDE automatically performs a validation check before deployment and validates your template against common failure causes, including:

  • Invalid property syntax or schema mismatches: These issues are typically caught by cfn-lint during authoring, but if you proceed to deploy without addressing them, CloudFormation's deployment-time validation surfaces the same errors before the stack is created or updated.

  • Resource name conflicts with existing resources in your account.

  • Service-specific constraints, such as S3 bucket name conflicts or missing encryption.

If the validation detects errors, the IDE highlights the issues directly in your template and lists the errors in the diagnostics panel. Each issue includes the specific property or resource that caused the failure, along with a suggested fix. If there are no blocking errors, you can proceed to the deployment phase.

If warnings are found (non-blocking issues), a dialog appears allowing you to either proceed with deployment or cancel and make corrections.

The IDE opens a drift-aware change set that displays any differences between your current template and the deployed stack configuration. This allows you to review, confirm, or cancel the change set before execution. Cancelling the deployment deletes the change set.

Drift-aware change sets enhance the CloudFormation deployment process by allowing you to handle stack drift safely. Stack drift occurs when the actual state of your resources differs from what is defined in your CloudFormation template, often due to manual changes made through the AWS Management Console, CLI, or SDK. CloudFormation drift-aware change sets compare your processed stack configuration with the live resource state, and the IDE surfaces these differences so you can bring resources back into compliance before deployment.

View stack events

When the deployment starts, you can monitor progress in real time from the CloudFormation panel. Under Stack Events, you see a list of operations performed during the deployment. Each event includes details such as:

  • Timestamp: The time the event occurred

  • Resource: The specific AWS resource being created, updated, or deleted

  • Status: The current state of the operation (for example, CREATE_IN_PROGRESS, UPDATE_COMPLETE, or ROLLBACK_IN_PROGRESS)

  • Reason: Additional context or error messages, if applicable

You can also view the stack's Resources and Outputs from this panel. The Stack Events view helps you track deployment progress, identify potential issues, and confirm when your stack has completed successfully.

Initializing a CloudFormation project in the IDE (VS Code only)

Initializing a CloudFormation project in the IDE helps you set up a structured workspace with the correct folders and environment configuration for service-side validation and deployment. These online workflows require AWS credentials, but the Language Server's local authoring and static validation features don't. You can initialize a new CloudFormation project directly from the IDE to create this recommended setup. This feature is currently available in VS Code only and is not supported in JetBrains IDEs.

To initialize a CloudFormation project:

  • Open the command palette

    • From VS Code, open the command palette (Ctrl+Shift+P or Cmd+Shift+P on macOS).

    • Choose AWS CloudFormation: CFN Init: Initialize Project.

  • Choose a project directory

    • By default, the IDE uses your current working directory.

    • You can change this path to any folder where you want to store your CloudFormation templates.

  • Select your AWS credential profile

    • You are prompted to choose an AWS credential profile. The selected profile is used for environment detection, service-side validation, and deployment.

  • Set up your environment

    • You are prompted to create or select an environment.

    • Environments define where and how your templates are deployed or validated (for example, dev, beta, or production). You can use AWS CloudFormation: CFN Init: Add Environment to select or change your environment.

    • You can use AWS CloudFormation: CFN Init: Remove Environment to remove the environment you have selected.

  • (Optional) Import parameter files

    • If you already have existing parameter files, the IDE allows you to import them during initialization.

    • The IDE automatically detects compatible files and links them to your project for use in template validation and deployment.

  • Name and finalize the project

    • Provide a project name, such as beta-environment, and complete the setup.

    • The IDE creates the initial project structure and configuration file for you.

You can run validations, preview deployments, or switch between environments directly from the IDE.

Open source

The CloudFormation Language Server is open-sourced under the Apache-2.0 License, giving customers full transparency into how template diagnostics, schema validation, and static analysis are performed. This reduces security and compliance friction for customers who require source-level visibility before adopting tooling.

The code base is publicly available on GitHub: https://github.com/aws-cloudformation/cloudformation-languageserver/.

Need help?

Try the CloudFormation community on AWS re:Post.