Skip to content

Commit 2ccc2bf

Browse files
authored
Merge pull request #4 from strongdm/chore-add-private-gateway-deployment-in-example
feat: add support for private gateway deployment and custom AMI configuration
2 parents 280ca97 + 691d983 commit 2ccc2bf

9 files changed

Lines changed: 682 additions & 146 deletions

File tree

Readme.md

Lines changed: 158 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,195 @@
1-
# StrongDM AWS Terraform Module Template
1+
# StrongDM AWS Terraform Module
22

3-
This template provides a foundation for creating AWS-based StrongDM deployments using Terraform.
3+
This module deploys StrongDM gateway instances on AWS EC2.
44

5-
## Standards & Requirements
5+
## Features
66

7-
### Tagging Standards
8-
You can optionally provide tags to be applied to all resources. The module automatically adds these standard tags:
9-
- `ManagedBy`: "terraform"
10-
- `Application`: "strongdm"
11-
- `Name`: Resource identifier (from gateway_instance_name)
7+
- AWS EC2 instance provisioning for StrongDM gateways
8+
- Support for public and private subnet deployments
9+
- Custom AMI support with automatic latest AMI lookup fallback
10+
- Automatic tagging with standard metadata
11+
- IMDSv2 enforcement and encrypted root volumes
12+
- Flexible node naming options
1213

13-
To add your own tags, use the `tags` variable:
14+
## Usage
15+
16+
### Basic Usage (Public Gateway)
1417

1518
```hcl
16-
module "strongdm_aws" {
17-
source = "strongdm/sdm-gateway"
18-
19-
// Required parameters
20-
aws_region = "us-west-2"
21-
name = "aws-production-gateway"
22-
vpc_id = "vpc-xxxxxxxx"
23-
subnet_id = "subnet-xxxxxxxx"
24-
25-
// Optional: Custom tags
26-
tags = {
19+
module "sdm_gateway" {
20+
source = "git::https://github.com/strongdm/terraform-aws-sdm-gateway.git"
21+
22+
aws_region = "us-west-2"
23+
aws_vpc_id = "vpc-xxxxxxxx"
24+
aws_subnet_id = "subnet-xxxxxxxx"
25+
aws_security_group_id = "sg-xxxxxxxx"
26+
sdm_admin_token_secret_name = "sdm-admin-token"
27+
sdm_admin_token_secret_key = "admin_token"
28+
sdm_gateway_instance_name = "sdm-gateway-prod"
29+
sdm_node_name = "sdm-gateway-prod"
30+
31+
aws_tags = {
2732
Environment = "Production"
2833
Owner = "platform-team"
29-
Project = "strongdm-infrastructure"
30-
CostCenter = "IT-123"
3134
}
3235
}
3336
```
3437

35-
## Features
36-
- AWS-specific resource provisioning for StrongDM gateways
37-
- Standardized module structure for consistency
38-
- Automatic tagging with standard metadata
39-
- Support for custom tags
38+
### Private Gateway (No Public IP)
39+
40+
For deployments in private subnets without internet-facing IP addresses:
4041

41-
## Usage
4242
```hcl
43-
module "strongdm_aws" {
44-
source = "strongdm/sdm-gateway"
45-
46-
// Required parameters
47-
aws_region = "us-west-2"
48-
name = "aws-production-gateway"
49-
vpc_id = "vpc-xxxxxxxx"
50-
subnet_id = "subnet-xxxxxxxx"
51-
52-
// Required: Compliance tags
53-
tags = {
43+
module "sdm_gateway_private" {
44+
source = "git::https://github.com/strongdm/terraform-aws-sdm-gateway.git"
45+
46+
aws_region = "us-west-2"
47+
aws_vpc_id = "vpc-xxxxxxxx"
48+
aws_subnet_id = "subnet-private-xxxxxxxx"
49+
aws_security_group_id = "sg-xxxxxxxx"
50+
sdm_admin_token_secret_name = "sdm-admin-token"
51+
sdm_admin_token_secret_key = "admin_token"
52+
sdm_gateway_instance_name = "sdm-gateway-private"
53+
sdm_node_name = "sdm-gateway-private"
54+
55+
associate_public_ip_address = false
56+
57+
aws_tags = {
5458
Environment = "Production"
5559
Owner = "platform-team"
56-
Project = "strongdm-infrastructure"
5760
}
5861
}
5962
```
6063

64+
Note: Private gateways require outbound internet connectivity via NAT Gateway to reach the StrongDM control plane.
65+
66+
### Custom AMI
67+
68+
To use a specific AMI instead of the latest StrongDM gateway AMI:
69+
70+
```hcl
71+
module "sdm_gateway" {
72+
source = "git::https://github.com/strongdm/terraform-aws-sdm-gateway.git"
73+
74+
ami_id = "ami-0123456789abcdef0"
75+
76+
# ... other required variables
77+
}
78+
```
79+
6180
## Requirements
62-
- Terraform >= 1
63-
- AWS provider >= 4.0
64-
- Valid StrongDM API credentials
65-
- Valid AWS credentials
6681

67-
## Inputs, Outputs, and Resources
68-
See the respective documentation files for details.
82+
| Name | Version |
83+
|------|---------|
84+
| Terraform | >= 1.0 |
85+
| AWS Provider | >= 5.0 |
86+
87+
## Inputs
88+
89+
| Name | Description | Type | Default | Required |
90+
|------|-------------|------|---------|:--------:|
91+
| aws_region | The AWS region to deploy resources to | `string` | n/a | yes |
92+
| aws_vpc_id | The VPC ID where the gateway instance will be deployed | `string` | n/a | yes |
93+
| aws_subnet_id | The subnet ID where the gateway instance will be deployed | `string` | n/a | yes |
94+
| aws_security_group_id | Security group for the SDM gateway | `string` | n/a | yes |
95+
| sdm_admin_token_secret_name | The name of the AWS Secrets Manager secret containing the SDM admin token | `string` | n/a | yes |
96+
| sdm_admin_token_secret_key | The key name in the AWS Secrets Manager secret for the SDM admin token | `string` | n/a | yes |
97+
| ami_id | Optional AMI ID to use. If not specified, uses the latest StrongDM gateway AMI | `string` | `""` | no |
98+
| associate_public_ip_address | Whether to associate a public IP address with the gateway instance | `bool` | `true` | no |
99+
| aws_iam_instance_profile | The name of the IAM instance profile to attach to the EC2 instance | `string` | `""` | no |
100+
| aws_instance_type | The instance type for the gateway instance | `string` | `"t3.medium"` | no |
101+
| aws_tags | Optional tags to apply to all resources | `map(string)` | `{}` | no |
102+
| sdm_app_domain | The StrongDM control plane domain the gateway connects to | `string` | `"app.strongdm.com"` | no |
103+
| sdm_gateway_instance_name | The name of the gateway instance | `string` | `""` | no |
104+
| sdm_node_name | The StrongDM node name to register the gateway with | `string` | `""` | no |
105+
| sdm_use_instance_name | Use the instance name as the StrongDM node name | `bool` | `false` | no |
106+
107+
## Outputs
108+
109+
| Name | Description |
110+
|------|-------------|
111+
| vpc_id | VPC ID |
112+
| subnet_id | Subnet ID |
113+
| default_tags | Standard tags applied to all resources |
114+
| ec2_instance_public_ip | EC2 instance public IP |
115+
| ec2_instance_public_dns | EC2 instance public DNS |
116+
| gateway_instance_name | Name of the StrongDM gateway instance |
117+
118+
## Tagging Standards
119+
120+
The module automatically adds these standard tags to all resources:
121+
- `ManagedBy`: "terraform"
122+
- `Application`: "strongdm"
123+
- `Name`: Resource identifier (from gateway_instance_name)
124+
125+
Custom tags can be added via the `aws_tags` variable and will be merged with the standard tags.
69126

70127
## Example Deployment
71128

72-
A complete example deployment is provided in the [`example/`](./example/) directory. This includes:
73-
- Example `main.tf` showing how to use the module with two gateway instances
74-
- Example `variables.tf` and `terraform.tfvars.example` for required variables
75-
- Example `outputs.tf` to expose useful outputs
129+
A complete self-contained example is provided in the [`example/`](./example/) directory. This includes:
130+
131+
- Full VPC infrastructure (VPC, subnets, Internet Gateway, NAT Gateway, route tables)
132+
- Security groups and IAM roles
133+
- VPC endpoints for AWS services (SSM, Secrets Manager)
134+
- Four gateway deployment examples:
135+
1. Public gateway with custom node name
136+
2. Public gateway using instance name as node name
137+
3. Public gateway with auto-generated node name
138+
4. Private gateway without public IP (uses NAT Gateway)
76139

77140
To try the example:
78-
1. Copy `example/terraform.tfvars.example` to `example/terraform.tfvars` and fill in your values.
79-
2. Run `terraform init` and `terraform apply` inside the `example/` directory.
80141

81-
Refer to the files in `example/` for a practical usage reference.
142+
1. Copy `example/terraform.tfvars.example` to `example/terraform.tfvars` and fill in your values
143+
2. Run `terraform init` inside the `example/` directory
144+
3. Run `terraform apply`
145+
146+
## Security Features
147+
148+
- IMDSv2 is required (http_tokens = "required")
149+
- Root block device encryption is enabled by default
150+
- Metadata endpoint is enabled for instance configuration
82151

83152
## Contributing
84153

85154
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for detailed information about:
86155

87-
- **Commit Message Standards**: We use [Conventional Commits](https://www.conventionalcommits.org/) for consistent commit messages
88-
- **Development Workflow**: Setup, testing, and submission process
89-
- **Code Standards**: Terraform and Go formatting requirements
156+
- Commit Message Standards: We use [Conventional Commits](https://www.conventionalcommits.org/)
157+
- Development Workflow: Setup, testing, and submission process
158+
- Code Standards: Terraform and Go formatting requirements
159+
160+
### Running Tests
90161

91-
### Quick Start for Contributors
162+
```bash
163+
# Run all static analysis (fmt, lint, validate)
164+
make all-static
92165

93-
1. **Static Analysis**: `make all-static`
94-
2. **Run Integration Tests**: `go test -v ./tests/integration`
95-
3. **With direnv**: `direnv exec . go test -v ./tests/integration`
96-
4. **Terraform test (unit tests)**terraform test -test-directory ./tests/unit`
166+
# Run unit tests
167+
make unit-test
168+
169+
# Run integration tests
170+
make integration-test
171+
172+
# Run all tests (unit + integration)
173+
make test
174+
```
175+
176+
Individual commands:
177+
178+
```bash
179+
# Format code
180+
make fmt
181+
182+
# Lint with tfsec and tflint
183+
make lint
184+
185+
# Validate terraform
186+
make validate
187+
188+
# Install required tools (macOS)
189+
make bootstrap
190+
```
97191

98192
### Quick References
99-
- **[Contributing Guide](CONTRIBUTING.md)**: Complete development workflow and standards
100-
- **[Commit Reference](docs/COMMIT_REFERENCE.md)**: Quick lookup for commit message format
193+
194+
- [Contributing Guide](CONTRIBUTING.md): Complete development workflow and standards
195+
- [Commit Reference](docs/COMMIT_REFERENCE.md): Quick lookup for commit message format

0 commit comments

Comments
 (0)