-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
134 lines (128 loc) · 3.49 KB
/
template.yaml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
SAM Template for dotnet-poc
Parameters:
DBServer:
Description: "The database server name"
Type: String
DBName:
Description: "The database name"
Type: String
DBUser:
Description: "The database user"
Type: String
DBPassword:
Description: "The database password"
Type: String
DBPort:
Description: "The database port"
Type: String
TableName:
Description: "The table name"
Type: String
Globals:
Function:
Timeout: 10
MemorySize: 128
LoggingConfig:
LogFormat: JSON
Resources:
PutS3ObjectFunction:
Type: AWS::Serverless::Function
Properties:
Handler: PutS3Object::PutS3Object.Function::FunctionHandler
Runtime: dotnet6
CodeUri: ./src/PutS3Object
Architectures:
- x86_64
MemorySize: 256
Timeout: 30
Policies:
- AWSLambdaBasicExecutionRole
- AmazonS3FullAccess
Environment:
Variables:
BucketName: !Ref DotNetPOCBucket
TableName: !Ref TableName
DBName: !Ref DBName
DBServer: !Ref DBServer
DBUser: !Ref DBUser
DBPassword: !Ref DBPassword
DBPort: !Ref DBPort
Events:
PutS3ObjectApi:
Type: Api
Properties:
Path: /putObject
Method: post
GetFileDetailsFunction:
Type: AWS::Serverless::Function
Properties:
Handler: GetFileDetails::GetFileRecord.Function::FunctionHandler
Runtime: dotnet6
CodeUri: ./src/GetFileDetails
Architectures:
- x86_64
MemorySize: 256
Timeout: 30
Policies:
- AWSLambdaBasicExecutionRole
Environment:
Variables:
TableName: !Ref TableName
DBName: !Ref DBName
DBServer: !Ref DBServer
DBUser: !Ref DBUser
DBPassword: !Ref DBPassword
DBPort: !Ref DBPort
Events:
GetFileDetailsApi:
Type: Api
Properties:
Path: /getFileDetails
Method: get
DotNetPOCBucket:
Type: "AWS::S3::Bucket"
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
BucketName: !Sub ${AWS::StackName}-file-bucket
VersioningConfiguration:
Status: Enabled
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
MainBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref DotNetPOCBucket
PolicyDocument:
Id: PublicReadPolicy
Version: 2012-10-17
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: "*"
Action: "s3:GetObject"
Resource: !Sub arn:aws:s3:::${DotNetPOCBucket}/public-assets/*
- Sid: PublicWriteForPutBucketObjects
Effect: Allow
Principal: "*"
Action: "s3:PutObject"
Resource: !Sub arn:aws:s3:::${DotNetPOCBucket}/public-assets/*
ApplicationResourceGroup:
Type: AWS::ResourceGroups::Group
Properties:
Name:
Fn::Sub: ApplicationInsights-SAM-${AWS::StackName}
ResourceQuery:
Type: CLOUDFORMATION_STACK_1_0
ApplicationInsightsMonitoring:
Type: AWS::ApplicationInsights::Application
Properties:
ResourceGroupName:
Ref: ApplicationResourceGroup
AutoConfigurationEnabled: "true"