Skip to content

Commit

Permalink
New Resource: Container Public Domain Names (#23)
Browse files Browse the repository at this point in the history
* New Resource: Container Public Domain Names

Co-Authored-By: Frank Xu <[email protected]>
  • Loading branch information
brittandeyoung and KaguraKagura authored Apr 4, 2022
1 parent d9e432a commit 9651d5f
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 16 deletions.
8 changes: 8 additions & 0 deletions docs/resources/certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ In addition to all arguments above, the following attributes are exported:
* `created_at` - The timestamp when the instance was created.
* `domain_validation_options` - Set of domain validation objects which can be used to complete certificate validation. Can have more than one element, e.g., if SANs are defined.
* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block.

## Import

`awslightsail_certificate` can be imported using the certificate name, e.g.

```shell
$ terraform import awslightsail_certificate.test CertificateName
```
2 changes: 2 additions & 0 deletions docs/resources/container_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ description: |-

# Resource: awslightsail_container_deployment

Deploys configured containers to an existing Container Service.

An Amazon Lightsail container service is a highly scalable compute and networking resource on which you can deploy, run,
and manage containers. For more information, see
[Container services in Amazon Lightsail](https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-container-services).
Expand Down
83 changes: 83 additions & 0 deletions docs/resources/container_public_domain_names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
page_title: "AWS Lightsail: awslightsail_container_public_domain_names"
description: |-
Provides a resource to manage Lightsail container public domain names
---

# Resource: awslightsail_container_public_domain_names

Public domain names to be configured as the public endpoint of your container service. Example: www.testdomain.com

An Amazon Lightsail container service is a highly scalable compute and networking resource on which you can deploy, run,
and manage containers. For more information, see
[Container services in Amazon Lightsail](https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-container-services).

**Note:** For more information about the AWS Regions in which you can create Amazon Lightsail container services,
see ["Regions and Availability Zones in Amazon Lightsail"](https://lightsail.aws.amazon.com/ls/docs/overview/article/understanding-regions-and-availability-zones-in-amazon-lightsail).

## Example Usage

```terraform
# create a new Lightsail container service
resource "awslightsail_container_service" "test" {
name = "container-service-1"
power = "nano"
scale = 1
is_disabled = false
tags = {
foo1 = "bar1"
foo2 = ""
}
}
resource "awslightsail_certificate" "test" {
name = "ExsitingCertificate"
domain_name = "existingdomain1.com"
subject_alternative_names = [
"www.existingdomain1.com"
]
}
resource "awslightsail_container_public_domain_names" "test" {
container_service_name = awslightsail_container_service.test.id
public_domain_names {
certificate {
certificate_name = awslightsail_certificate.test.name
domain_names = [
"existingdomain1.com",
"www.existingdomain1.com",
]
}
}
}
```

## Argument Reference

The following arguments are supported:

* `container_service_name` - (Required) The name for the container service.
* `public_domain_names` - (Required) The public domain names to use with the container service, such as example.com
and www.example.com. You can specify up to four public domain names for a container service. The domain names that you
specify are used when you create a deployment with a container configured as the public endpoint of your container
service.
* `certificate` - (Required) Describes the details of an SSL/TLS certificate for a container service.
* `certificate_name` - (Required) The certificate's name.
* `domain_names` - (Required) The domain names. A list of string.

WARNING: You must create and validate an SSL/TLS certificate before you can use public domain names with your container service. For more information, see [Enabling and managing custom domains for your Amazon Lightsail container services](https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-creating-container-services-certificates).

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - Same as `container_service_name`.

## Import

`awslightsail_container_public_domain_names` can be imported using the container service name, e.g.

```shell
$ terraform import awslightsail_container_public_domain_names.test container-service-1
```
1 change: 1 addition & 0 deletions internal/lightsail/container_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func resourceContainerDeploymentRead(d *schema.ResourceData, meta interface{}) e

csd := resp.Deployments[0]

d.Set("container_service_name", d.Id())
d.Set("container", flattenLightsailContainerServiceDeploymentContainers(csd.Containers))
d.Set("public_endpoint", flattenLightsailContainerServiceDeploymentPublicEndpoint(csd.PublicEndpoint))
d.Set("state", csd.State)
Expand Down
16 changes: 16 additions & 0 deletions internal/lightsail/container_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func testAccContainerDeployment_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "1"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test1"),
Expand All @@ -67,6 +68,7 @@ func testAccContainerDeployment_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "2"),
resource.TestCheckResourceAttr(rName, "container.#", "2"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test1"),
Expand All @@ -86,6 +88,7 @@ func testAccContainerDeployment_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "3"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test3"),
Expand All @@ -112,6 +115,7 @@ func testAccContainerDeployment_ContainerEnvironment(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "1"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -131,6 +135,7 @@ func testAccContainerDeployment_ContainerEnvironment(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "2"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -150,6 +155,7 @@ func testAccContainerDeployment_ContainerEnvironment(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "3"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -174,6 +180,7 @@ func testAccContainerDeployment_ContainerEnvironment(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "4"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -200,6 +207,7 @@ func testAccContainerDeployment_ContainerPort(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "1"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -219,6 +227,7 @@ func testAccContainerDeployment_ContainerPort(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "2"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -238,6 +247,7 @@ func testAccContainerDeployment_ContainerPort(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "3"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -262,6 +272,7 @@ func testAccContainerDeployment_ContainerPort(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "4"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test"),
Expand All @@ -288,6 +299,7 @@ func testAccContainerServiceDeployment_PublicEndpoint(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "1"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test1"),
Expand All @@ -311,6 +323,7 @@ func testAccContainerServiceDeployment_PublicEndpoint(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "2"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test2"),
Expand All @@ -334,6 +347,7 @@ func testAccContainerServiceDeployment_PublicEndpoint(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "3"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test2"),
Expand All @@ -357,6 +371,7 @@ func testAccContainerServiceDeployment_PublicEndpoint(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "4"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test2"),
Expand All @@ -380,6 +395,7 @@ func testAccContainerServiceDeployment_PublicEndpoint(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckContainerDeploymentExists(rName),
resource.TestCheckResourceAttr(rName, "state", "ACTIVE"),
resource.TestCheckResourceAttr(rName, "container_service_name", lName),
resource.TestCheckResourceAttr(rName, "version", "5"),
resource.TestCheckResourceAttr(rName, "container.#", "1"),
resource.TestCheckResourceAttr(rName, "container.0.container_name", "test2"),
Expand Down
Loading

0 comments on commit 9651d5f

Please sign in to comment.