-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodebuild-lambda.tf
More file actions
92 lines (80 loc) · 2.24 KB
/
Copy pathcodebuild-lambda.tf
File metadata and controls
92 lines (80 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
resource "aws_codebuild_project" "lambda_codebuild" {
name = "${var.name}-build"
description = "lambda function codebuild build project."
build_timeout = "30"
service_role = aws_iam_role.lambda_codebuild.arn
artifacts {
type = "CODEPIPELINE"
artifact_identifier = "build"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/standard:5.0"
privileged_mode = true
type = "LINUX_CONTAINER"
image_pull_credentials_type = "CODEBUILD"
environment_variable {
name = "AWS_DEFAULT_REGION"
value = data.aws_region.current.name
}
environment_variable {
name = "AWS_ACCOUNT_ID"
value = data.aws_caller_identity.current.account_id
}
}
source {
type = "CODEPIPELINE"
buildspec = <<BUILDSPEC
version: 0.2
phases:
build:
commands:
- cd ./function
- zip --recurse-paths ../lambda.zip *
artifacts:
files:
- 'lambda.zip'
BUILDSPEC
}
tags = local.common_tags
}
resource "aws_codebuild_project" "lambda_codedeploy" {
name = "${var.name}-deploy"
description = "lambda function codebuild deploy project."
build_timeout = "30"
service_role = aws_iam_role.lambda_codebuild.arn
artifacts {
type = "CODEPIPELINE"
artifact_identifier = "build"
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/standard:5.0"
privileged_mode = true
type = "LINUX_CONTAINER"
image_pull_credentials_type = "CODEBUILD"
environment_variable {
name = "AWS_DEFAULT_REGION"
value = data.aws_region.current.name
}
environment_variable {
name = "AWS_ACCOUNT_ID"
value = data.aws_caller_identity.current.account_id
}
}
#todo: Change this in a way that it uses codedeploy instead of codebuild
source {
type = "CODEPIPELINE"
buildspec = <<BUILDSPEC
version: 0.2
phases:
build:
commands:
- aws lambda update-function-code --function-name ${aws_lambda_function.this.function_name} --zip-file fileb://$CODEBUILD_SRC_DIR/lambda.zip --publish
artifacts:
files:
- '**/*'
BUILDSPEC
}
tags = local.common_tags
}