Skip to content

Commit bf54345

Browse files
authored
feat(aws_instance): conditional IAM instance profile (#182)
* feat(aws_instance): conditional IAM instance profile
1 parent d4045d9 commit bf54345

File tree

5 files changed

+72
-135
lines changed

5 files changed

+72
-135
lines changed

README.md

Lines changed: 56 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11

22
<!-- markdownlint-disable -->
3-
# terraform-aws-ec2-instance [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-ec2-instance.svg)](https://github.com/cloudposse/terraform-aws-ec2-instance/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
3+
# terraform-aws-ec2-instance<a href="https://cpco.io/homepage"><img align="right" src="https://cloudposse.com/logo-300x69.svg" width="150" /></a> [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-ec2-instance.svg)](https://github.com/cloudposse/terraform-aws-ec2-instance/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
44
<!-- markdownlint-restore -->
55

6-
[![README Header][readme_header_img]][readme_header_link]
7-
8-
[![Cloud Posse][logo]](https://cpco.io/homepage)
96

107
<!--
118
@@ -36,57 +33,32 @@ Included features:
3633
* CloudWatch monitoring and automatic reboot if instance hangs
3734
* Assume Role capability
3835

39-
---
40-
41-
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
42-
43-
44-
[![Terraform Open Source Modules](https://docs.cloudposse.com/images/terraform-open-source-modules.svg)][terraform_modules]
45-
46-
47-
48-
It's 100% Open Source and licensed under the [APACHE2](LICENSE).
49-
50-
51-
52-
53-
54-
55-
56-
We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out!
57-
58-
59-
6036

37+
---
38+
> [!NOTE]
39+
> This project is part of Cloud Posse's comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
40+
> <a href="https://cpco.io/terraform-modules"><img src="https://docs.cloudposse.com/images/terraform-open-source-modules.svg" align="right" /></a>
41+
>
42+
> It's 100% Open Source and licensed under the [APACHE2](LICENSE).
43+
>
44+
> We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out!
6145
46+
[![README Header][readme_header_img]][readme_header_link]
6247

63-
## Security & Compliance [<img src="https://cloudposse.com/wp-content/uploads/2020/11/bridgecrew.svg" width="250" align="right" />](https://bridgecrew.io/)
6448

65-
Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance.
6649

67-
| Benchmark | Description |
68-
|--------|---------------|
69-
| [![Infrastructure Security](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/general)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=INFRASTRUCTURE+SECURITY) | Infrastructure Security Compliance |
70-
| [![CIS KUBERNETES](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/cis_kubernetes)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=CIS+KUBERNETES+V1.5) | Center for Internet Security, KUBERNETES Compliance |
71-
| [![CIS AWS](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=CIS+AWS+V1.2) | Center for Internet Security, AWS Compliance |
72-
| [![CIS AZURE](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/cis_azure)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=CIS+AZURE+V1.1) | Center for Internet Security, AZURE Compliance |
73-
| [![PCI-DSS](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/pci)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=PCI-DSS+V3.2) | Payment Card Industry Data Security Standards Compliance |
74-
| [![NIST-800-53](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/nist)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=NIST-800-53) | National Institute of Standards and Technology Compliance |
75-
| [![ISO27001](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/iso)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=ISO27001) | Information Security Management System, ISO/IEC 27001 Compliance |
76-
| [![SOC2](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/soc2)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=SOC2)| Service Organization Control 2 Compliance |
77-
| [![CIS GCP](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/cis_gcp)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=CIS+GCP+V1.1) | Center for Internet Security, GCP Compliance |
78-
| [![HIPAA](https://www.bridgecrew.cloud/badges/github/cloudposse/terraform-aws-ec2-instance/hipaa)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-ec2-instance&benchmark=HIPAA) | Health Insurance Portability and Accountability Compliance |
7950

51+
## Usage
8052

8153

82-
## Usage
8354

55+
> **Important**
56+
> We do not pin modules to versions in Cloud Posse's examples because of the
57+
> difficulty of keeping the versions in the documentation in sync with the latest released versions.
58+
> We highly recommend that in your code you pin the version to the exact version you are
59+
> using so that your infrastructure remains stable, and update versions in a
60+
> systematic way so that they do not catch you by surprise.
8461
85-
**IMPORTANT:** We do not pin modules to versions in our examples because of the
86-
difficulty of keeping the versions in the documentation in sync with the latest released versions.
87-
We highly recommend that in your code you pin the version to the exact version you are
88-
using so that your infrastructure remains stable, and update versions in a
89-
systematic way so that they do not catch you by surprise.
9062

9163

9264
Note: add `${var.ssh_key_pair}` private key to the `ssh agent`.
@@ -275,6 +247,7 @@ Available targets:
275247
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
276248
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
277249
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
250+
| <a name="input_instance_profile_enabled"></a> [instance\_profile\_enabled](#input\_instance\_profile\_enabled) | Whether an IAM instance profile is created to pass a role to an Amazon EC2 instance when the instance starts | `bool` | `true` | no |
278251
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance | `string` | `"t2.micro"` | no |
279252
| <a name="input_ipv6_address_count"></a> [ipv6\_address\_count](#input\_ipv6\_address\_count) | Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet (-1 to use subnet default) | `number` | `0` | no |
280253
| <a name="input_ipv6_addresses"></a> [ipv6\_addresses](#input\_ipv6\_addresses) | List of IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `[]` | no |
@@ -351,13 +324,6 @@ Available targets:
351324
<!-- markdownlint-restore -->
352325

353326

354-
355-
## Share the Love
356-
357-
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-ec2-instance)! (it helps us **a lot**)
358-
359-
360-
361327
## Related Projects
362328

363329
Check out these related projects.
@@ -375,70 +341,22 @@ For additional context, refer to some of these links.
375341
- [terraform-aws-ec2-bastion-server](https://github.com/cloudposse/terraform-aws-ec2-bastion-server) - Terraform Module to define a generic Bastion host with parameterized user_data
376342

377343

378-
## Help
379-
380-
**Got a question?** We got answers.
381-
382-
File a GitHub [issue](https://github.com/cloudposse/terraform-aws-ec2-instance/issues), send us an [email][email] or join our [Slack Community][slack].
383-
384-
[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link]
385-
386-
## DevOps Accelerator for Startups
387-
388-
389-
We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us.
390-
391-
[![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support]
392-
393-
Work directly with our team of DevOps experts via email, slack, and video conferencing.
394-
395-
We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet.
396-
397-
- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code.
398-
- **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments.
399-
- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices.
400-
- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes.
401-
- **GitOps.** You'll be able to operate your infrastructure via Pull Requests.
402-
- **Training.** You'll receive hands-on training so your team can operate what we build.
403-
- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel.
404-
- **Troubleshooting.** You'll get help to triage when things aren't working.
405-
- **Code Reviews.** You'll receive constructive feedback on Pull Requests.
406-
- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects.
407-
408-
## Slack Community
409-
410-
Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure.
411-
412-
## Newsletter
413-
414-
Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
415-
416-
## Office Hours
417-
418-
[Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone!
419-
420-
[![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours]
421-
422344
## ✨ Contributing
423345

424-
425-
426346
This project is under active development, and we encourage contributions from our community.
427347
Many thanks to our outstanding contributors:
428348

429349
<a href="https://github.com/cloudposse/terraform-aws-ec2-instance/graphs/contributors">
430350
<img src="https://contrib.rocks/image?repo=cloudposse/terraform-aws-ec2-instance&max=24" />
431351
</a>
432352

433-
434-
435-
### Bug Reports & Feature Requests
353+
### 🐛 Bug Reports & Feature Requests
436354

437355
Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-ec2-instance/issues) to report any bugs or file feature requests.
438356

439-
### Developing
357+
### 💻 Developing
440358

441-
If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email].
359+
If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with Cloud Posse's other projects, we would love to hear from you! Shoot us an [email][email].
442360

443361
In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
444362

@@ -450,13 +368,43 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
450368

451369
**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!
452370

371+
### 🌎 Slack Community
453372

454-
## Copyright
373+
Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure.
455374

456-
Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright)
375+
### 📰 Newsletter
376+
377+
Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
378+
379+
### 📆 Office Hours <img src="https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png" align="right" />
380+
381+
[Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone!
382+
383+
## About
384+
385+
This project is maintained and funded by [Cloud Posse, LLC][website].
386+
<a href="https://cpco.io/homepage"><img src="https://cloudposse.com/logo-300x69.svg" align="right" /></a>
387+
388+
We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us.
389+
390+
[![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support]
391+
392+
Work directly with our team of DevOps experts via email, slack, and video conferencing.
457393

394+
We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet.
458395

396+
- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code.
397+
- **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments.
398+
- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices.
399+
- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes.
400+
- **GitOps.** You'll be able to operate your infrastructure via Pull Requests.
401+
- **Training.** You'll receive hands-on training so your team can operate what we build.
402+
- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel.
403+
- **Troubleshooting.** You'll get help to triage when things aren't working.
404+
- **Code Reviews.** You'll receive constructive feedback on Pull Requests.
405+
- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects.
459406

407+
[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link]
460408
## License
461409

462410
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -482,29 +430,12 @@ specific language governing permissions and limitations
482430
under the License.
483431
```
484432

485-
486-
487-
488-
489-
490-
491-
492-
493433
## Trademarks
494434

495435
All other trademarks referenced herein are the property of their respective owners.
496-
497-
## About
498-
499-
This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]!
500-
501-
[![Cloud Posse][logo]][website]
502-
503-
We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source].
504-
505-
We offer [paid support][commercial_support] on all of our projects.
506-
507-
Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation.[![README Footer][readme_footer_img]][readme_footer_link]
436+
---
437+
Copyright © 2017-2024 [Cloud Posse, LLC](https://cpco.io/copyright)
438+
[![README Footer][readme_footer_img]][readme_footer_link]
508439
[![Beacon][beacon]][website]
509440
<!-- markdownlint-disable -->
510441
[logo]: https://cloudposse.com/logo-300x69.svg
@@ -515,7 +446,6 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
515446
[hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=hire
516447
[slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=slack
517448
[twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=twitter
518-
[testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=testimonial
519449
[office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=office_hours
520450
[newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=newsletter
521451
[email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-ec2-instance&utm_content=email

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
8989
| <a name="input_instance_initiated_shutdown_behavior"></a> [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Specifies whether an instance stops or terminates when you initiate shutdown from the instance. Can be one of 'stop' or 'terminate'. | `string` | `null` | no |
9090
| <a name="input_instance_profile"></a> [instance\_profile](#input\_instance\_profile) | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
91+
| <a name="input_instance_profile_enabled"></a> [instance\_profile\_enabled](#input\_instance\_profile\_enabled) | Whether an IAM instance profile is created to pass a role to an Amazon EC2 instance when the instance starts | `bool` | `true` | no |
9192
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The type of the instance | `string` | `"t2.micro"` | no |
9293
| <a name="input_ipv6_address_count"></a> [ipv6\_address\_count](#input\_ipv6\_address\_count) | Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet (-1 to use subnet default) | `number` | `0` | no |
9394
| <a name="input_ipv6_addresses"></a> [ipv6\_addresses](#input\_ipv6\_addresses) | List of IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `[]` | no |

0 commit comments

Comments
 (0)