This repository was archived by the owner on Apr 3, 2022. It is now read-only.
File tree 7 files changed +79
-25
lines changed
7 files changed +79
-25
lines changed Original file line number Diff line number Diff line change 26
26
- stage : delete
27
27
name : Delete all created resources
28
28
script :
29
- - " ./bin/terraform destroy -auto-approve terraform"
29
+ # - "./bin/terraform destroy -auto-approve terraform"
30
+ - echo "Will currently not delete anything."
Original file line number Diff line number Diff line change @@ -35,6 +35,4 @@ Die Lambda Funktionen werden automatisch verpackt und bei Änderungen hochgelade
35
35
36
36
### Lambda
37
37
38
- ### DynamoDb
39
-
40
38
### API Gateway
Original file line number Diff line number Diff line change
1
+ const handler = ( event , _ , callback ) => {
2
+ var response = {
3
+ statusCode : 200 ,
4
+ headers : {
5
+ 'Content-Type' : 'text/html; charset=utf-8' ,
6
+ } ,
7
+ body : "<p>Hello world!</p>" ,
8
+ } ;
9
+ callback ( null , response ) ;
10
+ }
11
+
12
+ module . exports = {
13
+ handler
14
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ resource "aws_api_gateway_deployment" "helloWorldGateway" {
2
+ depends_on = [
3
+ " aws_api_gateway_integration.helloWorldGet"
4
+ ]
5
+
6
+ rest_api_id = " ${ aws_api_gateway_rest_api . helloWorldGateway . id } "
7
+ stage_name = " beta"
8
+ }
9
+
10
+ resource "aws_api_gateway_rest_api" "helloWorldGateway" {
11
+ name = " helloWorldApiGateway"
12
+ description = " Hello world example"
13
+
14
+ }
15
+
16
+ resource "aws_api_gateway_resource" "helloWorld" {
17
+ rest_api_id = " ${ aws_api_gateway_rest_api . helloWorldGateway . id } "
18
+ parent_id = " ${ aws_api_gateway_rest_api . helloWorldGateway . root_resource_id } "
19
+ path_part = " hello"
20
+ }
21
+
22
+ resource "aws_api_gateway_method" "helloWorldGet" {
23
+ rest_api_id = " ${ aws_api_gateway_rest_api . helloWorldGateway . id } "
24
+ resource_id = " ${ aws_api_gateway_resource . helloWorld . id } "
25
+ http_method = " GET"
26
+ authorization = " NONE"
27
+ }
28
+
29
+ resource "aws_api_gateway_integration" "helloWorldGet" {
30
+ rest_api_id = " ${ aws_api_gateway_rest_api . helloWorldGateway . id } "
31
+ resource_id = " ${ aws_api_gateway_resource . helloWorld . id } "
32
+ http_method = " ${ aws_api_gateway_method . helloWorldGet . http_method } "
33
+ integration_http_method = " POST"
34
+ type = " AWS_PROXY"
35
+ uri = " ${ aws_lambda_function . schibbler_helloWorldLambda . invoke_arn } "
36
+ }
37
+
38
+ output "Gateway_URL" {
39
+ value = " ${ aws_api_gateway_deployment . helloWorldGateway . invoke_url } "
40
+ }
Original file line number Diff line number Diff line change 1
- data "aws_iam_policy_document" "loginLambda_policy " {
1
+ data "aws_iam_policy_document" "helloWorldLambda_policy " {
2
2
statement {
3
3
actions = [" sts:AssumeRole" ]
4
4
principals {
@@ -9,14 +9,14 @@ data "aws_iam_policy_document" "loginLambda_policy" {
9
9
}
10
10
}
11
11
12
- resource "aws_iam_role" "loginLambda " {
13
- name = " schibbler_loginLambda_iam "
12
+ resource "aws_iam_role" "helloWorldLambda " {
13
+ name = " schibbler_helloWorldLambda_role "
14
14
15
- assume_role_policy = " ${ data . aws_iam_policy_document . loginLambda_policy . json } "
15
+ assume_role_policy = " ${ data . aws_iam_policy_document . helloWorldLambda_policy . json } "
16
16
}
17
17
18
18
19
- resource "aws_iam_role_policy_attachment" "loginLambda_policyAttachment " {
20
- role = " ${ aws_iam_role . loginLambda . name } "
19
+ resource "aws_iam_role_policy_attachment" "helloWorldLambda_policyAttachment " {
20
+ role = " ${ aws_iam_role . helloWorldLambda . name } "
21
21
policy_arn = " arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
22
22
}
Original file line number Diff line number Diff line change 1
- data "archive_file" "loginLambdaZip " {
1
+ data "archive_file" "helloWorldLambdaZip " {
2
2
type = " zip"
3
- source_dir = " functions/loginLambda "
4
- output_path = " output/loginLambda .zip"
3
+ source_dir = " functions/helloWorldLambda "
4
+ output_path = " output/helloWorldLambda .zip"
5
5
}
6
6
7
- resource "aws_lambda_function" "schibbler_loginLambda " {
8
- filename = " output/loginLambda .zip"
9
- source_code_hash = " ${ data . archive_file . loginLambdaZip . output_base64sha256 } "
10
- function_name = " schibblerLoginLambda "
7
+ resource "aws_lambda_function" "schibbler_helloWorldLambda " {
8
+ filename = " output/helloWorldLambda .zip"
9
+ source_code_hash = " ${ data . archive_file . helloWorldLambdaZip . output_base64sha256 } "
10
+ function_name = " schibblerhelloWorldLambda "
11
11
handler = " index.handler"
12
- role = " ${ aws_iam_role . loginLambda . arn } "
12
+ role = " ${ aws_iam_role . helloWorldLambda . arn } "
13
13
runtime = " nodejs8.10"
14
+ }
15
+
16
+ resource "aws_lambda_permission" "restInvokation" {
17
+ statement_id = " AllowExecutionFromAPIGateway"
18
+ action = " lambda:InvokeFunction"
19
+ function_name = " ${ aws_lambda_function . schibbler_helloWorldLambda . arn } "
20
+ principal = " apigateway.amazonaws.com"
21
+
22
+ source_arn = " ${ aws_api_gateway_deployment . helloWorldGateway . execution_arn } /GET/hello"
14
23
}
You can’t perform that action at this time.
0 commit comments