Skip to content

Commit afd7766

Browse files
Merge pull request #8 from docusign/lightsail
Migrated to Lightsail
2 parents c2acb7d + d39bf76 commit afd7766

7 files changed

Lines changed: 184 additions & 141 deletions

File tree

terraform/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The directory structure is organized to support deploying the extension app to d
133133
- `README.md`: The main documentation file.
134134
- `aws/`: Contains Terraform configuration files for deploying to Amazon Web Services.
135135
- `README.md`: Documentation specific to AWS deployment.
136-
- `apprunner.tf`, `ecr.tf`, `image.tf`, `main.tf`, `outputs.tf`, `providers.tf`, `terraform.tf`, `variables.tf`: Various Terraform configuration files for AWS resources.
136+
- `ecr.tf`, `image.tf`, `lightsail.tf`, `main.tf`, `outputs.tf`, `providers.tf`, `terraform.tf`, `variables.tf`: Various Terraform configuration files for AWS resources.
137137
- `azure/`: Contains Terraform configuration files for deploying to Microsoft Azure.
138138
- `README.md`: Documentation specific to Azure deployment.
139139
- `acr.tf`, `image.tf`, `main.tf`, `outputs.tf`, `providers.tf`, `resource_group.tf`, `terraform.tf`, `variables.tf`, `webapp.tf`: Various Terraform configuration files for Azure resources.
@@ -156,9 +156,9 @@ The directory structure is organized to support deploying the extension app to d
156156
├── README.md
157157
├── aws
158158
│   ├── README.md
159-
│   ├── apprunner.tf
160159
│   ├── ecr.tf
161160
│   ├── image.tf
161+
│   ├── lightsail.tf
162162
│   ├── main.tf
163163
│   ├── outputs.tf
164164
│   ├── providers.tf

terraform/aws/.terraform.lock.hcl

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/aws/README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Now that you’ve set up your AWS environment, continue with the [Terraform depl
4040
| Name | Version |
4141
|------|---------|
4242
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |
43-
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.12 |
4443

4544
## Modules
4645

@@ -57,17 +56,12 @@ Now that you’ve set up your AWS environment, continue with the [Terraform depl
5756

5857
| Name | Type |
5958
|------|------|
60-
| [aws_apprunner_service.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apprunner_service) | resource |
6159
| [aws_ecr_repository.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository) | resource |
6260
| [aws_ecr_repository_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository_policy) | resource |
63-
| [aws_iam_role.access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
64-
| [aws_iam_role.instance](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
65-
| [aws_iam_role_policy_attachment.apprunner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
66-
| [time_sleep.access_iam_role_propagation](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
61+
| [aws_lightsail_container_service.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lightsail_container_service) | resource |
62+
| [aws_lightsail_container_service_deployment_version.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lightsail_container_service_deployment_version) | resource |
6763
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
6864
| [aws_ecr_authorization_token.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source |
69-
| [aws_iam_policy_document.app_role_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
70-
| [aws_iam_policy_document.apprunner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
7165
| [aws_iam_policy_document.ecr](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
7266
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
7367

@@ -82,8 +76,8 @@ Now that you’ve set up your AWS environment, continue with the [Terraform depl
8276
| <a name="input_application_build_labels"></a> [application\_build\_labels](#input\_application\_build\_labels) | The labels to apply to the application build image | `map(string)` | <pre>{<br/> "org.opencontainers.image.authors": "DocuSign Inc.",<br/> "org.opencontainers.image.description": "This reference implementation models the implementation of connected fields functionalities in an extension app.",<br/> "org.opencontainers.image.licenses": "MIT",<br/> "org.opencontainers.image.source": "https://github.com/docusign/extension-app-connected-fields-reference-implementation",<br/> "org.opencontainers.image.title": "Connected Fields Extension App Reference Implementation",<br/> "org.opencontainers.image.vendor": "DocuSign Inc."<br/>}</pre> | no |
8377
| <a name="input_application_build_paths"></a> [application\_build\_paths](#input\_application\_build\_paths) | Paths of files relative to the build context, changes to which lead to a rebuild of the image. Supported pattern matches are the same as for the `fileset` Terraform function (https://developer.hashicorp.com/terraform/language/functions/fileset). | `list(string)` | <pre>[<br/> "public/**",<br/> "src/**",<br/> "views/**",<br/> "package.json",<br/> "tsconfig.json",<br/> "Dockerfile",<br/> ".dockerignore"<br/>]</pre> | no |
8478
| <a name="input_application_environment_mode"></a> [application\_environment\_mode](#input\_application\_environment\_mode) | The environment mode for the application | `string` | `"production"` | no |
85-
| <a name="input_application_instance_cpu"></a> [application\_instance\_cpu](#input\_application\_instance\_cpu) | The number of CPU units to allocate to the application instance | `string` | `"256"` | no |
86-
| <a name="input_application_instance_memory"></a> [application\_instance\_memory](#input\_application\_instance\_memory) | The amount of memory to allocate to the application instance | `string` | `"512"` | no |
79+
| <a name="input_application_instance_power"></a> [application\_instance\_power](#input\_application\_instance\_power) | The power specification for the Lightsail container service instance | `string` | `"nano"` | no |
80+
| <a name="input_application_instance_scale"></a> [application\_instance\_scale](#input\_application\_instance\_scale) | The number of Lightsail container service instances to run | `number` | `1` | no |
8781
| <a name="input_application_jwt_secret_key"></a> [application\_jwt\_secret\_key](#input\_application\_jwt\_secret\_key) | The secret key to use for signing JWT tokens. If empty, a random key will be generated. | `string` | `""` | no |
8882
| <a name="input_application_name"></a> [application\_name](#input\_application\_name) | The name of the application | `string` | `"extension-app-connected-fields"` | no |
8983
| <a name="input_application_oauth_client_id"></a> [application\_oauth\_client\_id](#input\_application\_oauth\_client\_id) | The OAuth client ID for the application. If empty, a random client ID will be generated. | `string` | `""` | no |

terraform/aws/apprunner.tf

Lines changed: 0 additions & 86 deletions
This file was deleted.

terraform/aws/ecr.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ data "aws_iam_policy_document" "ecr" {
4242
]
4343
}
4444
}
45+
46+
statement {
47+
actions = [
48+
"ecr:BatchGetImage",
49+
"ecr:GetDownloadUrlForLayer",
50+
]
51+
52+
principals {
53+
type = "AWS"
54+
identifiers = [
55+
aws_lightsail_container_service.this.private_registry_access[0].ecr_image_puller_role[0].principal_arn,
56+
]
57+
}
58+
}
4559
}
4660

4761
resource "aws_ecr_repository_policy" "this" {

terraform/aws/lightsail.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
locals {
2+
application_service_url = trimsuffix(aws_lightsail_container_service.this.url, "/")
3+
}
4+
5+
resource "aws_lightsail_container_service" "this" {
6+
name = var.application_name
7+
power = var.application_instance_power
8+
scale = var.application_instance_scale
9+
10+
private_registry_access {
11+
ecr_image_puller_role {
12+
is_active = true
13+
}
14+
}
15+
16+
tags = local.tags
17+
}
18+
19+
resource "aws_lightsail_container_service_deployment_version" "this" {
20+
container {
21+
container_name = var.application_name
22+
image = module.image.app_image_name
23+
24+
environment = {
25+
JWT_SECRET_KEY = local.application_jwt_secret_key
26+
OAUTH_CLIENT_ID = local.application_oauth_client_id
27+
OAUTH_CLIENT_SECRET = local.application_oauth_client_secret
28+
AUTHORIZATION_CODE = local.application_authorization_code
29+
}
30+
31+
ports = {
32+
(var.application_port) = "HTTP"
33+
}
34+
}
35+
36+
public_endpoint {
37+
container_name = var.application_name
38+
container_port = var.application_port
39+
40+
health_check {
41+
path = "/"
42+
success_codes = "200-499"
43+
}
44+
}
45+
46+
service_name = aws_lightsail_container_service.this.name
47+
}

terraform/aws/variables.tf

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -103,59 +103,27 @@ variable "application_build_labels" {
103103
}
104104
}
105105

106-
variable "application_instance_cpu" {
107-
description = "The number of CPU units to allocate to the application instance"
106+
variable "application_instance_power" {
107+
description = "The power specification for the Lightsail container service instance"
108108
type = string
109109
nullable = false
110-
default = "256"
110+
default = "nano"
111111

112112
validation {
113-
condition = contains(
114-
[
115-
"256",
116-
"512",
117-
"1024",
118-
"2048",
119-
"4096",
120-
"0.25 vCPU",
121-
"0.5 vCPU",
122-
"1 vCPU",
123-
"2 vCPU",
124-
"4 vCPU",
125-
], var.application_instance_cpu)
126-
error_message = "The number of CPU units must be one of '256', '512', '1024', '2048', '4096', '0.25 vCPU', '0.5 vCPU', '1 vCPU', '2 vCPU', or '4 vCPU'"
113+
condition = contains(["nano", "micro", "small", "medium", "large", "xlarge"], var.application_instance_power)
114+
error_message = "The instance power must be one of 'nano', 'micro', 'small', 'medium', 'large', or 'xlarge'"
127115
}
128116
}
129117

130-
variable "application_instance_memory" {
131-
description = "The amount of memory to allocate to the application instance"
132-
type = string
118+
variable "application_instance_scale" {
119+
description = "The number of Lightsail container service instances to run"
120+
type = number
133121
nullable = false
134-
default = "512"
122+
default = 1
135123

136124
validation {
137-
condition = contains(
138-
[
139-
"512",
140-
"1024",
141-
"2048",
142-
"3072",
143-
"4096",
144-
"6144",
145-
"8192",
146-
"10240",
147-
"12288",
148-
"0.5 GB",
149-
"1 GB",
150-
"2 GB",
151-
"3 GB",
152-
"4 GB",
153-
"6 GB",
154-
"8 GB",
155-
"10 GB",
156-
"12 GB",
157-
], var.application_instance_memory)
158-
error_message = "The amount of memory must be one of '512', '1024', '2048', '3072', '4096', '6144', '8192', '10240', '12288', '0.5 GB', '1 GB', '2 GB', '3 GB', '4 GB', '6 GB', '8 GB', '10 GB', or '12 GB'"
125+
condition = var.application_instance_scale >= 1 && var.application_instance_scale <= 20
126+
error_message = "The instance scale must be between 1 and 20"
159127
}
160128
}
161129

0 commit comments

Comments
 (0)