Skip to content

Commit 17cbbd5

Browse files
updated all TF files to version 0.12.19
1 parent 13e8d07 commit 17cbbd5

12 files changed

+135
-31
lines changed

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,101 @@
11
# aws-lambda-encrypt-ami
2-
Lambda function triggered by SNS notification on a successful AMI Packer build.
2+
3+
[![OSO DevOps][logo]](https://osodevops.io)
4+
5+
---
6+
7+
This Terraform module creates an encryption Lambda function that is triggered by a SNS notification on a successful AMI Packer build.
8+
9+
This project is part of our open source DevOps adoption approach.
10+
11+
It's 100% Open Source and licensed under the [APACHE2](LICENSE).
12+
13+
## Usage
14+
15+
Include this repository as a module in your existing terraform code:
16+
```hcl
17+
module "codebuild" {
18+
source = "git::ssh://[email protected]/osodevops/aws-lambda-encrypt-ami.git"
19+
common_tags = "${var.common_tags}"
20+
environment = "DEV"
21+
kms_key_arn = "alias/foo-bar-key"
22+
```
23+
24+
## Help
25+
26+
**Got a question?**
27+
28+
File a GitHub [issue](https://github.com/osodevops/aws-lambda-encrypt-ami/issues), send us an [email][email] or tweet us [twitter][twitter].
29+
30+
## Contributing
31+
32+
### Bug Reports & Feature Requests
33+
34+
Please use the [issue tracker](https://github.com/osodevops/aws-lambda-encrypt-ami/issues) to report any bugs or file feature requests.
35+
36+
### Developing
37+
38+
If you are interested in being a contributor and want to get involved in developing this project or help out with our other projects, we would love to hear from you! Shoot us an [email][email].
39+
40+
In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
41+
42+
1. **Fork** the repo on GitHub
43+
2. **Clone** the project to your own machine
44+
3. **Commit** changes to your own branch
45+
4. **Push** your work back up to your fork
46+
5. Submit a **Pull Request** so that we can review your changes
47+
48+
**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!
49+
50+
## Copyrights
51+
52+
Copyright © 2018-2019 [OSO DevOps](https://osodevops.io)
53+
54+
## License
55+
56+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
57+
58+
See [LICENSE](LICENSE) for full details.
59+
60+
Licensed to the Apache Software Foundation (ASF) under one
61+
or more contributor license agreements. See the NOTICE file
62+
distributed with this work for additional information
63+
regarding copyright ownership. The ASF licenses this file
64+
to you under the Apache License, Version 2.0 (the
65+
"License"); you may not use this file except in compliance
66+
with the License. You may obtain a copy of the License at
67+
68+
https://www.apache.org/licenses/LICENSE-2.0
69+
70+
Unless required by applicable law or agreed to in writing,
71+
software distributed under the License is distributed on an
72+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
73+
KIND, either express or implied. See the License for the
74+
specific language governing permissions and limitations
75+
under the License.
76+
77+
## Trademarks
78+
79+
All other trademarks referenced herein are the property of their respective owners.
80+
81+
## About
82+
83+
[![OSO DevOps][logo]][website]
84+
85+
We are a cloud consultancy specialising in transforming technology organisations through DevOps practices. We help organisations accelerate their capabilities for application delivery and minimize the time-to-market for software-driven innovation.
86+
87+
Check out [our other projects][github], [follow us on twitter][twitter], or [hire us][hire] to help with your cloud strategy and implementation.
88+
89+
90+
91+
92+
[![README Footer][readme_footer_img]][readme_footer_link]
93+
[![Beacon][beacon]][website]
94+
95+
[logo]: https://osodevops.io/assets/images/logo-purple-b3af53cc.svg
96+
[website]: https://osodevops.io/
97+
[github]: https://github.com/orgs/osodevops/
98+
[hire]: https://osodevops.io/contact/
99+
[linkedin]: https://www.linkedin.com/company/oso-devops
100+
[twitter]: https://twitter.com/osodevops
101+
[email]: https://www.osodevops.io/contact/

aws_cloudwatch_event_rule_build_success.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ resource "aws_cloudwatch_event_rule" "build_alert" {
2222

2323
resource "aws_cloudwatch_event_target" "lamba_alert" {
2424
# Create ami encryption target
25-
rule = "${aws_cloudwatch_event_rule.build_alert.name}"
25+
rule = aws_cloudwatch_event_rule.build_alert.name
2626
target_id = "ami-encryption-lambda"
27-
arn = "${aws_lambda_function.ami_encryption_lambda.arn}"
27+
arn = aws_lambda_function.ami_encryption_lambda.arn
2828
}
2929

aws_lambda_function.tf

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
resource "aws_lambda_function" "ami_encryption_lambda" {
2-
filename = "${data.archive_file.ami_encryption.0.output_path}"
3-
description = "Responsible for creating AMI with encrypted root volume."
4-
function_name = "${upper(var.environment)}-AMI-ENCRYPTION-FUNCTION"
5-
6-
role = "${aws_iam_role.ami_encrypt_lambda.arn}"
7-
handler = "ami_encryption.lambda_handler"
8-
runtime = "python3.6"
9-
timeout = 180
10-
source_code_hash = "${data.archive_file.ami_encryption.0.output_base64sha256}"
2+
filename = data.archive_file.ami_encryption.0.output_path
3+
description = "Responsible for creating AMI with encrypted root volume."
4+
function_name = "${upper(var.environment)}-AMI-ENCRYPTION-FUNCTION"
5+
role = aws_iam_role.ami_encrypt_lambda.arn
6+
handler = "ami_encryption.lambda_handler"
7+
runtime = "python3.6"
8+
timeout = 180
9+
source_code_hash = data.archive_file.ami_encryption.0.output_base64sha256
1110

1211
environment {
1312
variables = {
1413
KMS_ENABLED = "True"
15-
KMS_KEY = "${var.kms_key_arn}"
14+
KMS_KEY = var.kms_key_arn
1615
}
1716
}
1817

19-
tags = "${merge(var.common_tags,
20-
map("Name" , "${var.environment}-AMI-ENCRYPTION-LAMBDA")
21-
)}"
18+
tags = merge(
19+
var.common_tags,
20+
{
21+
"Name" = "${var.environment}-AMI-ENCRYPTION-LAMBDA"
22+
},
23+
)
2224
}

aws_lambda_iam_policy.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ resource "aws_iam_policy" "ami_encryption_policy" {
33
path = "/"
44
description = "AMI encryption Lambda function policy to access EC2 and CloudWatch"
55

6-
policy = "${data.aws_iam_policy_document.lambda_config_policy.json}"
6+
policy = data.aws_iam_policy_document.lambda_config_policy.json
77
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_policy_attachment" "ami_encryption_policy" {
22
name = "ami-encryption-attachment"
3-
roles = ["${aws_iam_role.ami_encrypt_lambda.name}"]
4-
policy_arn = "${aws_iam_policy.ami_encryption_policy.arn}"
3+
roles = [aws_iam_role.ami_encrypt_lambda.name]
4+
policy_arn = aws_iam_policy.ami_encryption_policy.arn
55
}

aws_lambda_iam_role.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_role" "ami_encrypt_lambda" {
22
name = "${var.environment}-AMI-ENCRYPTION-LAMBDA-ROLE"
33
description = "Allows Lambda function to execute AMI copy with encrypted root volume."
4-
assume_role_policy = "${data.aws_iam_policy_document.lambda_config_trust.json}"
4+
assume_role_policy = data.aws_iam_policy_document.lambda_config_trust.json
55
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "aws_lambda_permission" "cloudwatch_event" {
22
statement_id = "AllowExecutionFromCloudWatchEvent"
33
action = "lambda:InvokeFunction"
4-
function_name = "${aws_lambda_function.ami_encryption_lambda.0.function_name}"
4+
function_name = aws_lambda_function.ami_encryption_lambda.0.function_name
55
principal = "events.amazonaws.com"
6-
source_arn = "${aws_cloudwatch_event_rule.build_alert.arn}"
6+
source_arn = aws_cloudwatch_event_rule.build_alert.arn
77
}

data_archive_file_ami_backup.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
data "archive_file" "ami_encryption" {
22
type = "zip"
3-
source_file = "${data.null_data_source.lambda_file.outputs.filename}"
4-
output_path = "${data.null_data_source.lambda_archive.outputs.filename}"
3+
source_file = data.null_data_source.lambda_file.outputs.filename
4+
output_path = data.null_data_source.lambda_archive.outputs.filename
55
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
data "null_data_source" "lambda_archive" {
2-
inputs {
3-
filename = "${substr("${path.module}/functions/ami_encryption.zip", length(path.cwd) + 1, -1)}"
2+
inputs = {
3+
filename = substr("${path.module}/functions/ami_encryption.zip", length(path.cwd) + 1, -1)
44
}
5-
}
5+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
data "null_data_source" "lambda_file" {
2-
inputs {
3-
filename = "${substr("${path.module}/functions/ami_encryption.py", length(path.cwd) + 1, -1)}"
2+
inputs = {
3+
filename = substr("${path.module}/functions/ami_encryption.py", length(path.cwd) + 1, -1)
44
}
55
}

0 commit comments

Comments
 (0)