Skip to content

Commit b4b6488

Browse files
committed
Update Terraform article
1 parent 4320fef commit b4b6488

File tree

2 files changed

+73
-60
lines changed

2 files changed

+73
-60
lines changed

docs/api/about-apis/intro-to-apis.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
1111

1212
Sumo Logic has a host of useful APIs across all products that can add valuable functionality to any organization by providing access to data and activities without going through the website. API calls can be used for data gathering, automation of processes, and custom reports.
1313

14-
This article presumes that you have a solid understanding of Sumo Logic functionality: collectors, queries, security offerings, etc. While the use of APIs are typically for "power users" looking for additional customization and access to web service resources, you also don't need a computer science degree to understand and make use of API calls. This article helps walk you through the basics and get you going with important data queries through the API.
14+
This article presumes that you have a solid understanding of Sumo Logic functionality: collectors, queries, security offerings, etc. While APIs are typically for "power users" looking for additional customization and access to web service resources, you also don't need a computer science degree to understand and make use of API calls. This article helps walk you through the basics and get you going with important data queries through the API.
1515

1616
In this article, you'll learn about:
1717
* How to create a Sumo Logic access ID/key.
1818
* How to access Sumo Logic APIs.
1919
* How to use APIs with Sumo Logic's Cloud SIEM.
20-
* How to use Terraform with a Sumo Logic AWS Installation.
21-
2220

2321
## Create an access key
2422

docs/api/about-apis/terraform-with-sumo-logic.md

Lines changed: 72 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,73 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
1313

1414
[Terraform](https://developer.hashicorp.com/terraform) is an "infrastructure as code" tool developed by Hashicorp. Terraform scripts are used to define both cloud and on-prem resources in human-readable configuration files. Using Terraform scripts makes it easier for system administrators to provision and manage infrastructure and system resources consistently and reliably. The Terraform community, including Sumo Logic, supports Terraform through providers and APIs allowing applications to install and manage different types of resources and services from different vendors in one workflow. See the [Terraform Sumo Logic provider](https://registry.terraform.io/namespaces/SumoLogic).
1515

16-
[How does Terraform work?](https://developer.hashicorp.com/terraform/intro#how-does-terraform-work) The core Terraform workflow consists of three stages:
17-
* **Write**. Define resources, which may be across multiple cloud providers and services. For example, you might create a configuration to deploy an AWS instance to support AWS Observability for a customer.
18-
* **Plan**. Create an execution plan describing the infrastructure it will create, update, or destroy based on the existing infrastructure and your configuration.
19-
* **Apply**. Once the plan is approved, Terraform performs the proposed operations in the correct order, respecting any resource dependencies.
16+
## Sumo Logic use cases
2017

21-
<img src={useBaseUrl('img/api/terraform-diagram.png')} alt="Terraform diagram" style={{border: '1px solid gray'}} width="700" />
18+
You can use Terraform to manage all sorts of Sumo Logic resources. Here are some use cases:
19+
* [Manage monitors](https://www.sumologic.com/blog/terraform-sumo-logic)
20+
* [Manage collectors, users, and roles](https://www.sumologic.com/blog/terraform-provider-hosted)
21+
* [Deploy solutions (like AWS Observability)](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/)
22+
23+
## Prequisites
24+
25+
To use Terraform with Sumo Logic, you need the following:
26+
* A Sumo Logic [account](/docs/get-started/sign-up/)
27+
* A Sumo Logic [access key](/docs/manage/security/access-keys/)
28+
* [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)
29+
30+
## Using Sumo Logic's AWS Terraform template
31+
32+
To illustrate how to use Terraform with Sumo Logic, we'll walk you through [how to deploy the Sumo Logic AWS Observability Solution with a Terraform template](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/). Sumo Logic has already established a Terraform template containing the basic script items needed to setup an AWS installation with the proper AWS and Sumo Logic resources and components.
33+
34+
To use this solution template, you should already have:
35+
* A Sumo Logic account.
36+
* An AWS account.
37+
* A [Sumo Logic access ID and access key](/docs/manage/security/access-keys/).
38+
39+
Perform the following steps to use the template:
40+
41+
1. The solution template files can be found [here](https://github.com/SumoLogic/sumologic-solution-templates/tree/master/aws-observability-terraform), in the Sumo Logic solution templates Github repository. To implement this solution, copy or clone the files in the repository to your server or local machine. For instance, from the command line, you can use the following command to clone the repository:<br/>`git clone https://github.com/SumoLogic/sumologic-solution-templates`
42+
1. In preparation, you will want to complete the following steps on your server or local machine:
43+
1. [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) (version 1.6 or later).
44+
1. [Install Python](https://www.python.org/downloads/) (version 3.11 or later).
45+
1. [Install the latest version of the "jq" JSON parser](https://github.com/jqlang/jq/wiki/Installation), necessary to run the `.sh` batch files in the template.
46+
1. [Install the Sumo Logic Python SDK](https://pypi.org/project/sumologic-sdk/).
47+
1. [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
48+
1. Next, navigate to the `sumologic-solution-templates` folder where you cloned the repository, and go to the `aws-observability-terraform` subdirectory. Set this directory to be the Terraform working directory by executing the following command: `terraform init`
49+
1. Using the solution template starts with [the main.auto.tfvars file](https://github.com/SumoLogic/sumologic-solution-templates/blob/master/aws-observability-terraform/main.auto.tfvars) which contains variable settings for your Sumo Logic organization, access ID and key, and other configuration information that will be referenced by the other template files. Open this file and fill in each field with the requested information.<br/><img src={useBaseUrl('img/api/tfvars-file.png')} alt="tfvars file" style={{border: '1px solid gray'}} width="800" /><br/>Check the [Sumo Logic API endpoints](/docs/api/about-apis/getting-started/#sumo-logic-endpoints-by-deployment-and-firewall-security) if you need help finding the proper deployment value to use.
50+
1. As part of the AWS Observability solution, we'll want to create and use the proper fields and FERs in Sumo Logic (see [here](/docs/observability/aws/deploy-use-aws-observability/resources/) for more details). Make sure you are in the `aws-observability-terraform` sub-directory, and run the following CLI commands (with the appropriate information included):
51+
```
52+
export SUMOLOGIC_ENV="YOUR_SUMOLOGIC_DEPLOYMENT"
53+
export SUMOLOGIC_ACCESSID="YOUR_SUMOLOGIC_ACCESS_ID"
54+
export SUMOLOGIC_ACCESSKEY="YOUR_SUMOLOGIC_ACCESS_KEY"
55+
```
56+
1. Then run the `fields.sh` script with the following command: `sh fields.sh`
57+
1. Next, let's look at the [providers.tf file](https://github.com/SumoLogic/sumologic-solution-templates/blob/master/aws-observability-terraform/providers.tf), which connects Terraform to the Sumo Logic and AWS provider plugins.<br/><img src={useBaseUrl('img/api/providers-tf-file.png')} alt="providers.tf file" style={{border: '1px solid gray'}} width="800" /> <br/>The Sumo Logic provider is already configured, as we can simply reference the environment and access key settings from the `tfvars` file configured earlier. For the AWS provider, change the region setting (if needed). Then, uncomment the `profile` and `alias` fields (lines 16 and 20, by deleting the `#`) and fill in the values using your AWS profile name (from the AWS CLI) and a custom alias to identify this provider.
58+
:::note
59+
This installation is assuming you are using a single AWS account in a single region. If you need to configure multiple AWS accounts and/or multiple regions, see [Option 2: Deploy to Multiple Regions within an AWS account](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/#option-2-deploy-to-multiple-regions-within-an-aws-account) for additional information on configuring the `providers.tf` file.
60+
:::
61+
1. Lastly, let's look at the [main.tf](https://github.com/SumoLogic/sumologic-solution-templates/blob/master/aws-observability-terraform/main.tf) file.<br/><img src={useBaseUrl('img/api/main-tf-file.png')} alt="main.tf file" style={{border: '1px solid gray'}} width="800" /> <br/>The top `sumo-module` section can usually be left alone unless there are [settings that need to be overridden](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/#appendix) for your install.<br/><br/>The bottom `collection-module` section is given as a template, but you will usually want to comment out this section (add `#` in front of every line) and create your own module definition using the AWS alias(es) defined in the `provider.tf` file earlier.<br/><br/>An example:
62+
```
63+
module "<ALIAS>" {
64+
source = "./source-module"
65+
providers = { aws = aws.<ALIAS> }
66+
67+
aws_account_alias = <var.aws_account_alias OR "account alias">
68+
sumologic_organization_id = var.sumologic_organization_id
69+
access_id = var.sumologic_access_id
70+
access_key = var.sumologic_access_key
71+
environment = var.sumologic_environment
72+
}
73+
```
74+
Substitute in the appropriate aliases for the ALIAS fields above. Note that if you are deploying for multiple regions and/or multiple AWS accounts, you'll need one new module section for each region defined in `provider.tf`. (See [more examples](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/#step-4-configure-providers-in-the-maintf-file) for multi-region and multi-account circumstances)
75+
1. We're finished. Let's deploy.
76+
<br/>Once the above files are configured, you can run Terraform against your scripts by executing the following CLI commands in sequence:
77+
```
78+
terraform validate
79+
terraform plan
80+
terraform apply
81+
```
82+
Terraform will report back during these processes if there are any issues with the text of the terraform files that needs troubleshooting.
2283
2384
## Understanding the Terraform format
2485
@@ -175,56 +236,10 @@ The state file is used by Terraform to track the current infrastructure state in
175236
176237
<img src={useBaseUrl('img/api/terraform-state-file.png')} alt="Terraform state file" style={{border: '1px solid gray'}} width="600" />
177238
178-
## Using Sumo Logic's AWS Terraform template
179-
180-
Since [setting up AWS Observability](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/) is a common use case, Sumo Logic has already established a Terraform template containing the basic script items needed to setup an AWS installation with the proper AWS and Sumo Logic resources and components.
239+
## Additional resources
181240
182-
To use this solution template, you should already have:
183-
* A Sumo Logic account.
184-
* An AWS account.
185-
* A [Sumo Logic access ID and access key](/docs/manage/security/access-keys/).
186-
187-
Perform the following steps to use the template:
188-
189-
1. The solution template files can be found [here](https://github.com/SumoLogic/sumologic-solution-templates/tree/master/aws-observability-terraform), in the Sumo Logic solution templates Github repository. To implement this solution, copy or clone the files in the repository to your server or local machine. For instance, from the command line, you can use the following command to clone the repository:<br/>`git clone https://github.com/SumoLogic/sumologic-solution-templates`
190-
1. In preparation, you will want to complete the following steps on your server or local machine:
191-
1. [Install Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) (version 1.6 or later).
192-
1. [Install Python](https://www.python.org/downloads/) (version 3.11 or later).
193-
1. [Install the latest version of the "jq" JSON parser](https://github.com/jqlang/jq/wiki/Installation), necessary to run the `.sh` batch files in the template.
194-
1. [Install the Sumo Logic Python SDK](https://pypi.org/project/sumologic-sdk/).
195-
1. [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
196-
1. Next, navigate to the `sumologic-solution-templates` folder where you cloned the repository, and go to the `aws-observability-terraform` subdirectory. Set this directory to be the Terraform working directory by executing the following command: `terraform init`
197-
1. Using the solution template starts with [the main.auto.tfvars file](https://github.com/SumoLogic/sumologic-solution-templates/blob/master/aws-observability-terraform/main.auto.tfvars) which contains variable settings for your Sumo Logic organization, access ID and key, and other configuration information that will be referenced by the other template files. Open this file and fill in each field with the requested information.<br/><img src={useBaseUrl('img/api/tfvars-file.png')} alt="tfvars file" style={{border: '1px solid gray'}} width="800" /><br/>Check the [Sumo Logic API endpoints](/docs/api/about-apis/getting-started/#sumo-logic-endpoints-by-deployment-and-firewall-security) if you need help finding the proper deployment value to use.
198-
1. As part of the AWS Observability solution, we'll want to create and use the proper fields and FERs in Sumo Logic (see [here](/docs/observability/aws/deploy-use-aws-observability/resources/) for more details). Make sure you are in the `aws-observability-terraform` sub-directory, and run the following CLI commands (with the appropriate information included):
199-
```
200-
export SUMOLOGIC_ENV="YOUR_SUMOLOGIC_DEPLOYMENT"
201-
export SUMOLOGIC_ACCESSID="YOUR_SUMOLOGIC_ACCESS_ID"
202-
export SUMOLOGIC_ACCESSKEY="YOUR_SUMOLOGIC_ACCESS_KEY"
203-
```
204-
1. Then run the `fields.sh` script with the following command: `sh fields.sh`
205-
1. Next, let's look at the [providers.tf file](https://github.com/SumoLogic/sumologic-solution-templates/blob/master/aws-observability-terraform/providers.tf), which connects Terraform to the Sumo Logic and AWS provider plugins.<br/><img src={useBaseUrl('img/api/providers-tf-file.png')} alt="providers.tf file" style={{border: '1px solid gray'}} width="800" /> <br/>The Sumo Logic provider is already configured, as we can simply reference the environment and access key settings from the `tfvars` file configured earlier. For the AWS provider, change the region setting (if needed). Then, uncomment the `profile` and `alias` fields (lines 16 and 20, by deleting the `#`) and fill in the values using your AWS profile name (from the AWS CLI) and a custom alias to identify this provider.
206-
:::note
207-
This installation is assuming you are using a single AWS account in a single region. If you need to configure multiple AWS accounts and/or multiple regions, see [Option 2: Deploy to Multiple Regions within an AWS account](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/#option-2-deploy-to-multiple-regions-within-an-aws-account) for additional information on configuring the `providers.tf` file.
208-
:::
209-
1. Lastly, let's look at the [main.tf](https://github.com/SumoLogic/sumologic-solution-templates/blob/master/aws-observability-terraform/main.tf) file.<br/><img src={useBaseUrl('img/api/main-tf-file.png')} alt="main.tf file" style={{border: '1px solid gray'}} width="800" /> <br/>The top `sumo-module` section can usually be left alone unless there are [settings that need to be overridden](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/#appendix) for your install.<br/><br/>The bottom `collection-module` section is given as a template, but you will usually want to comment out this section (add `#` in front of every line) and create your own module definition using the AWS alias(es) defined in the `provider.tf` file earlier.<br/><br/>An example:
210-
```
211-
module "<ALIAS>" {
212-
source = "./source-module"
213-
providers = { aws = aws.<ALIAS> }
214-
215-
aws_account_alias = <var.aws_account_alias OR "account alias">
216-
sumologic_organization_id = var.sumologic_organization_id
217-
access_id = var.sumologic_access_id
218-
access_key = var.sumologic_access_key
219-
environment = var.sumologic_environment
220-
}
221-
```
222-
Substitute in the appropriate aliases for the ALIAS fields above. Note that if you are deploying for multiple regions and/or multiple AWS accounts, you'll need one new module section for each region defined in `provider.tf`. (See [more examples](/docs/observability/aws/deploy-use-aws-observability/deploy-with-terraform/#step-4-configure-providers-in-the-maintf-file) for multi-region and multi-account circumstances)
223-
1. We're finished. Let's deploy.
224-
<br/>Once the above files are configured, you can run Terraform against your scripts by executing the following CLI commands in sequence:
225-
```
226-
terraform validate
227-
terraform plan
228-
terraform apply
229-
```
230-
Terraform will report back during these processes if there are any issues with the text of the terraform files that needs troubleshooting.
241+
* Blogs:
242+
* [How to Use the New Sumo Logic Terraform Provider for Hosted Collectors](https://www.sumologic.com/blog/terraform-provider-hosted)
243+
* [Terraform and Sumo Logic – Build Monitoring into your Cloud Infrastructure](https://www.sumologic.com/blog/terraform-sumo-logic)
244+
* Terraform resource: [Sumo Logic Provider](https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs)
245+
* GitHub: [terraform-provider-sumologic](https://github.com/SumoLogic/terraform-provider-sumologic)

0 commit comments

Comments
 (0)