> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/compute/appsec-aws-315.md).

# EC2 Auto Scaling groups are not utilizing EC2 launch templates misconfiguration detected in code

## Rule Details

|                        |                                         |
| ---------------------- | --------------------------------------- |
| Cortex AppSec Rule ID  | APPSEC\_AWS\_315                        |
| Category - Subcategory | Compute - Unsanctioned Resource Or Type |
| Provider               | AWS                                     |
| Severity               | MEDIUM                                  |
| Framework              | Terraform, Terraform Plan               |

## Impact

This rule is checking to verify that EC2 Auto Scaling groups in AWS are utilizing EC2 launch templates. EC2 launch templates define instance configuration for compute resources. They provide a way for you to save a launch configuration that you can reuse, which helps in maintaining the consistency of configurations and also speeds up the deployment process.

Not using EC2 launch templates can lead to several issues:

1. Inconsistency: Manual configuration for every instance may lead to inconsistencies and errors, which can in turn lead to security vulnerabilities.
2. Slow Deployment: Not using launch templates can result in a slower deployment process. Every time you need to launch a new instance, you would have to manually configure all the settings.
3. Troubleshooting Difficulty: If instances are manually configured, troubleshooting can become complex as you need to identify the configuration for each instance separately.
4. Scaling inefficiencies: Since auto-scaling groups adjust the number of instances on the fly according to load, not using a standard launch template would make this scaling inefficient and error-prone.

Therefore, it is important for the best practice and efficient deployments to use EC2 launch templates in AWS auto-scaling groups.

## How to Fix

*Resource:* aws\_autoscaling\_group

* *Arguments:* launch\_template

To fix this issue, you need to refactor the EC2 AutoScaling group resource to use EC2 launch templates, rather than launch configurations.

\[source,hcl]

```
resource "aws_launch_template" "example" {
 image_id = "ami-0c94855ba95c574c8"
 instance_type = "t2.micro"

 tags = {
 Name = "example"
 }
}

resource "aws_autoscaling_group" "example" {
 desired_capacity = 1
 max_size = 1
 min_size = 1

+ launch_template {
+ id = aws_launch_template.example.id
+ version = aws_launch_template.example.latest_version
+ }
}
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/compute/appsec-aws-315.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
