|  | 
| 1 |  | -# tf_kops_bootstrap | 
|  | 1 | +# terraform-aws-kops-state-backend [](https://travis-ci.org/cloudposse/terraform-aws-kops-state-backend) | 
|  | 2 | + | 
|  | 3 | +Terraform module to provision dependencies for `kops` (config S3 bucket & DNS zone). | 
|  | 4 | + | 
|  | 5 | +The module supports the following: | 
|  | 6 | + | 
|  | 7 | +1. Forced server-side encryption at rest for the S3 bucket | 
|  | 8 | +2. S3 bucket versioning to allow for `kops` state recovery in the case of accidental deletions or human errors | 
| 2 | 9 | 
 | 
| 3 |  | -Easily bootstrap dependencies for `kops` (config bucket & DNS zone) | 
| 4 | 10 | 
 | 
| 5 | 11 | ## Usage | 
| 6 | 12 | 
 | 
| 7 |  | -Provision environment for `foobar.example.com`. | 
|  | 13 | +This example will create a DNS zone called `kops.cloudxl.net` and delegate it from the parent zone `cloudxl.net` by setting `NS` and `SOA` records in the parent zone. | 
| 8 | 14 | 
 | 
| 9 |  | -``` | 
|  | 15 | +It will also create an S3 bucket with the name `cp-prod-kops-state` for storing `kops` manifests. | 
|  | 16 | + | 
|  | 17 | +```hcl | 
| 10 | 18 | module "kops" { | 
| 11 |  | -  source          = "git::https://github.com/cloudposse/tf_kops_bootstrap.git?ref=master" | 
| 12 |  | -  namespace       = "example" | 
| 13 |  | -  stage           = "dev" | 
| 14 |  | -  name            = "foobar" | 
| 15 |  | -  parent_dns_zone = "example.com" | 
|  | 19 | +  source           = "git::https://github.com/cloudposse/terraform-aws-kops-state-backend.git?ref=master" | 
|  | 20 | +  namespace        = "cp" | 
|  | 21 | +  stage            = "prod" | 
|  | 22 | +  name             = "kops" | 
|  | 23 | +  attributes       = ["state"] | 
|  | 24 | +  parent_zone_name = "cloudxl.net" | 
|  | 25 | +  zone_name        = "$${name}.$${parent_zone_name}" | 
|  | 26 | +  region           = "us-east-1" | 
|  | 27 | +} | 
|  | 28 | +``` | 
|  | 29 | + | 
|  | 30 | +<br/> | 
|  | 31 | + | 
|  | 32 | + | 
|  | 33 | + | 
|  | 34 | +<br/> | 
|  | 35 | + | 
|  | 36 | +To check that the created `kops` DNS zone has been tagged correctly, run | 
|  | 37 | + | 
|  | 38 | +```sh | 
|  | 39 | +aws route53 list-tags-for-resources --resource-type hostedzone --resource-ids Z58RWQWFVU4HT | 
|  | 40 | +``` | 
|  | 41 | + | 
|  | 42 | + | 
|  | 43 | +```js | 
|  | 44 | +{ | 
|  | 45 | +    "ResourceTagSets": [ | 
|  | 46 | +        { | 
|  | 47 | +            "ResourceType": "hostedzone", | 
|  | 48 | +            "ResourceId": "Z58RWQWFVU4HT", | 
|  | 49 | +            "Tags": [ | 
|  | 50 | +                { | 
|  | 51 | +                    "Key": "Cluster", | 
|  | 52 | +                    "Value": "kops.cloudxl.net" | 
|  | 53 | +                }, | 
|  | 54 | +                { | 
|  | 55 | +                    "Key": "Stage", | 
|  | 56 | +                    "Value": "prod" | 
|  | 57 | +                }, | 
|  | 58 | +                { | 
|  | 59 | +                    "Key": "Namespace", | 
|  | 60 | +                    "Value": "cp" | 
|  | 61 | +                }, | 
|  | 62 | +                { | 
|  | 63 | +                    "Key": "Name", | 
|  | 64 | +                    "Value": "cp-prod-kops-state" | 
|  | 65 | +                } | 
|  | 66 | +            ] | 
|  | 67 | +        } | 
|  | 68 | +    ] | 
| 16 | 69 | } | 
| 17 | 70 | ``` | 
| 18 | 71 | 
 | 
| 19 |  | -This example will create a DNS zone called `foobar.example.com` and delegate it from `example.com` by setting `NS` and `SOA` records. It will also provision a bucket called `config.foobar.example.com` for storing kops manifests. | 
|  | 72 | + | 
|  | 73 | +## Variables | 
|  | 74 | + | 
|  | 75 | +__NOTE:__ One of `parent_zone_name` or `parent_zone_id` is required, but not both. | 
|  | 76 | +The module will lookup the parent zone by either name or ID. | 
|  | 77 | + | 
|  | 78 | + | 
|  | 79 | +|  Name                    |  Default                          |  Description                                                                      | Required | | 
|  | 80 | +|:-------------------------|:----------------------------------|:----------------------------------------------------------------------------------|:--------:| | 
|  | 81 | +| `namespace`              | ``                                | Namespace (_e.g._ `cp` or `cloudposse`)                                           | Yes      | | 
|  | 82 | +| `stage`                  | ``                                | Stage (_e.g._ `prod`, `dev`, `staging`)                                           | Yes      | | 
|  | 83 | +| `region`                 | `us-east-1`                       | AWS Region the S3 bucket should reside in                                         | Yes      | | 
|  | 84 | +| `parent_zone_name`       | ``                                | Parent DNS zone name (e.g. `domain.com`). Required if `parent_zone_id` is not provided    | Yes      | | 
|  | 85 | +| `parent_zone_id`         | ``                                | Parent DNS zone ID. Required if `parent_zone_name` is not provided                | Yes      | | 
|  | 86 | +| `name`                   | `kops`                            | Name  (_e.g._ `kops`)                                                             | No       | | 
|  | 87 | +| `attributes`             | `["state"]`                       | Additional attributes (_e.g._ `state`)                                            | No       | | 
|  | 88 | +| `tags`                   | `{}`                              | Additional tags  (_e.g._ `map("BusinessUnit","XYZ")`                              | No       | | 
|  | 89 | +| `delimiter`              | `-`                               | Delimiter to be used between `namespace`, `stage`, `name`, and `attributes`       | No       | | 
|  | 90 | +| `acl`                    | `private`                         | The canned ACL to apply to the S3 bucket                                          | No       | | 
|  | 91 | +| `zone_name`              | `$${name}.$${parent_zone_name}`   | Template for `kops` DNS zone name                                                 | No       | | 
|  | 92 | +| `force_destroy`          | `false`                           | A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without errors   | No       | | 
|  | 93 | + | 
|  | 94 | + | 
|  | 95 | +## Outputs | 
|  | 96 | + | 
|  | 97 | +| Name                   | Description               | | 
|  | 98 | +|:-----------------------|:--------------------------| | 
|  | 99 | +| `parent_zone_id`       | Parent zone ID            | | 
|  | 100 | +| `parent_zone_name`     | Parent zone name          | | 
|  | 101 | +| `zone_id`              | `kops` zone ID            | | 
|  | 102 | +| `zone_name`            | `kops` zone name          | | 
|  | 103 | +| `bucket_name`          | S3 bucket name            | | 
|  | 104 | +| `bucket_region`        | S3 bucket region          | | 
|  | 105 | +| `bucket_domain_name`   | S3 bucket domain name     | | 
|  | 106 | +| `bucket_id`            | S3 bucket ID              | | 
|  | 107 | +| `bucket_arn`           | S3 bucket ARN             | | 
|  | 108 | + | 
|  | 109 | + | 
|  | 110 | +## Help | 
|  | 111 | + | 
|  | 112 | +**Got a question?** | 
|  | 113 | + | 
|  | 114 | +File a GitHub [ issue](https://github.com/cloudposse/terraform-aws-kops-state-backend/issues) , send us an [ email](mailto:[email protected])  or reach out to us on [ Gitter](https://gitter.im/cloudposse/) . | 
|  | 115 | + | 
|  | 116 | + | 
|  | 117 | +## Contributing | 
|  | 118 | + | 
|  | 119 | +### Bug Reports & Feature Requests | 
|  | 120 | + | 
|  | 121 | +Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-kops-state-backend/issues) to report any bugs or file feature requests. | 
|  | 122 | + | 
|  | 123 | +### Developing | 
|  | 124 | + | 
|  | 125 | +If you are interested in being a contributor and want to get involved in developing `terraform-aws-kops-state-backend` , we would love to hear from you! Shoot us an [ email](mailto:[email protected]) . | 
|  | 126 | + | 
|  | 127 | +In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. | 
|  | 128 | + | 
|  | 129 | + 1. **Fork** the repo on GitHub | 
|  | 130 | + 2. **Clone** the project to your own machine | 
|  | 131 | + 3. **Commit** changes to your own branch | 
|  | 132 | + 4. **Push** your work back up to your fork | 
|  | 133 | + 5. Submit a **Pull request** so that we can review your changes | 
|  | 134 | + | 
|  | 135 | +**NOTE:** Be sure to merge the latest from "upstream" before making a pull request! | 
|  | 136 | + | 
|  | 137 | + | 
|  | 138 | +## License | 
|  | 139 | + | 
|  | 140 | +[APACHE 2.0](LICENSE) © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com) | 
|  | 141 | + | 
|  | 142 | +See [LICENSE](LICENSE) for full details. | 
|  | 143 | + | 
|  | 144 | +    Licensed to the Apache Software Foundation (ASF) under one | 
|  | 145 | +    or more contributor license agreements.  See the NOTICE file | 
|  | 146 | +    distributed with this work for additional information | 
|  | 147 | +    regarding copyright ownership.  The ASF licenses this file | 
|  | 148 | +    to you under the Apache License, Version 2.0 (the | 
|  | 149 | +    "License"); you may not use this file except in compliance | 
|  | 150 | +    with the License.  You may obtain a copy of the License at | 
|  | 151 | + | 
|  | 152 | +      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 153 | + | 
|  | 154 | +    Unless required by applicable law or agreed to in writing, | 
|  | 155 | +    software distributed under the License is distributed on an | 
|  | 156 | +    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | 
|  | 157 | +    KIND, either express or implied.  See the License for the | 
|  | 158 | +    specific language governing permissions and limitations | 
|  | 159 | +    under the License. | 
|  | 160 | + | 
|  | 161 | + | 
|  | 162 | +## About | 
|  | 163 | + | 
|  | 164 | +`terraform-aws-kops-state-backend` is maintained and funded by [Cloud Posse, LLC][website]. | 
|  | 165 | + | 
|  | 166 | + | 
|  | 167 | + | 
|  | 168 | + | 
|  | 169 | +Like it? Please let us know at <[email protected]> | 
|  | 170 | + | 
|  | 171 | +We love [Open Source Software](https://github.com/cloudposse/)! | 
|  | 172 | + | 
|  | 173 | +See [our other projects][community] | 
|  | 174 | +or [hire us][hire] to help build your next cloud platform. | 
|  | 175 | + | 
|  | 176 | +  [website]: https://cloudposse.com/ | 
|  | 177 | +  [community]: https://github.com/cloudposse/ | 
|  | 178 | +  [hire]: https://cloudposse.com/contact/ | 
|  | 179 | + | 
|  | 180 | + | 
|  | 181 | +### Contributors | 
|  | 182 | + | 
|  | 183 | +| [![Erik Osterman][erik_img]][erik_web]<br/>[Erik Osterman][erik_web] | [![Andriy Knysh][andriy_img]][andriy_web]<br/>[Andriy Knysh][andriy_web] | | 
|  | 184 | +|-------------------------------------------------------|------------------------------------------------------------------| | 
|  | 185 | + | 
|  | 186 | +  [erik_img]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 | 
|  | 187 | +  [erik_web]: https://github.com/osterman/ | 
|  | 188 | +  [andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 | 
|  | 189 | +  [andriy_web]: https://github.com/aknysh/ | 
0 commit comments