|
| 1 | +# Golang Example |
| 2 | + |
| 3 | +A simple Go Lambda function with out of the box Datadog instrumentation. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +* Create a [Datadog API Key](https://app.datadoghq.com/organization-settings/api-keys) |
| 8 | +* Create a secret in [AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html) and add the Datadog API Key as the secret value in plaintext |
| 9 | +* Create a `terraform.tfvars` file |
| 10 | + - Set the `datadog_secret_arn` to the arn of the secret you just created |
| 11 | + - Set the `datadog_service_name` to the name of the service you want to use to filter for the resource in Datadog |
| 12 | + - Set the `datadog_site` to the [Datadog destination site](https://docs.datadoghq.com/getting_started/site/) for your metrics, traces, and logs |
| 13 | +* Run the following commands |
| 14 | + |
| 15 | +``` |
| 16 | +go mod tidy |
| 17 | +GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o bootstrap src/main.go |
| 18 | +terraform init |
| 19 | +terraform plan |
| 20 | +terraform apply |
| 21 | +``` |
| 22 | + |
| 23 | +<!-- BEGIN_TF_DOCS --> |
| 24 | +## Requirements |
| 25 | + |
| 26 | +| Name | Version | |
| 27 | +|------|---------| |
| 28 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0 | |
| 29 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.77.0 | |
| 30 | + |
| 31 | +## Providers |
| 32 | + |
| 33 | +| Name | Version | |
| 34 | +|------|---------| |
| 35 | +| <a name="provider_archive"></a> [archive](#provider\_archive) | 2.4.2 | |
| 36 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.77.0 | |
| 37 | + |
| 38 | +## Modules |
| 39 | + |
| 40 | +| Name | Source | Version | |
| 41 | +|------|--------|---------| |
| 42 | +| <a name="module_lambda-datadog"></a> [lambda-datadog](#module\_lambda-datadog) | ../../ | n/a | |
| 43 | + |
| 44 | +## Resources |
| 45 | + |
| 46 | +| Name | Type | |
| 47 | +|------|------| |
| 48 | +| [aws_iam_policy.secrets_manager_read_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | |
| 49 | +| [aws_iam_role.lambda_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | |
| 50 | +| [aws_iam_role_policy_attachment.attach_iam_policy_to_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | |
| 51 | +| [aws_iam_role_policy_attachment.attach_secrets_manager_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | |
| 52 | +| [archive_file.zip_code](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source | |
| 53 | + |
| 54 | +## Inputs |
| 55 | + |
| 56 | +| Name | Description | Type | Default | Required | |
| 57 | +|------|-------------|------|---------|:--------:| |
| 58 | +| <a name="input_datadog_secret_arn"></a> [datadog\_secret\_arn](#input\_datadog\_secret\_arn) | Secret for Datadog API Key | `string` | n/a | yes | |
| 59 | +| <a name="input_datadog_service_name"></a> [datadog\_service\_name](#input\_datadog\_service\_name) | Service used to filter for resources in Datadog | `string` | n/a | yes | |
| 60 | +| <a name="input_datadog_site"></a> [datadog\_site](#input\_datadog\_site) | Destination site for your metrics, traces, and logs | `string` | n/a | yes | |
| 61 | + |
| 62 | +## Outputs |
| 63 | + |
| 64 | +| Name | Description | |
| 65 | +|------|-------------| |
| 66 | +| <a name="output_arn"></a> [arn](#output\_arn) | Amazon Resource Name (ARN) identifying your Lambda Function. | |
| 67 | +| <a name="output_function_name"></a> [function\_name](#output\_function\_name) | Unique name for your Lambda Function | |
| 68 | +| <a name="output_invoke_arn"></a> [invoke\_arn](#output\_invoke\_arn) | ARN to be used for invoking Lambda Function from API Gateway. | |
| 69 | +<!-- END_TF_DOCS --> |
0 commit comments