File tree 4 files changed +70
-453
lines changed
4 files changed +70
-453
lines changed Original file line number Diff line number Diff line change
1
+ resource "aws_iam_role_policy_attachment" "data_scientist_attach" {
2
+ role = " switch-role-custom"
3
+ policy_arn = " arn:aws:iam::aws:policy/job-function/DataScientist"
4
+ }
5
+
1
6
resource "aws_iam_role" "sm_notebook_instance_role" {
2
7
name = " sm-notebook-instance-role"
3
8
@@ -87,6 +92,20 @@ resource "aws_iam_policy" "sm_notebook_instance_policy" {
87
92
"ec2:DescribeRouteTables"
88
93
],
89
94
"Resource": "*"
95
+ },
96
+ {
97
+ "Sid": "EnforceInstanceType",
98
+ "Effect": "Allow",
99
+ "Action": [
100
+ "sagemaker:CreateTrainingJob",
101
+ "sagemaker:CreateHyperParameterTuningJob"
102
+ ],
103
+ "Resource": "*",
104
+ "Condition": {
105
+ "ForAllValues:StringLike": {
106
+ "sagemaker:InstanceTypes": ["ml.t2.large"]
107
+ }
108
+ }
90
109
},
91
110
{
92
111
"Effect": "Allow",
Original file line number Diff line number Diff line change @@ -2,12 +2,3 @@ output "basic_notebook_instance_id" {
2
2
value = " ${ aws_sagemaker_notebook_instance . basic . id } "
3
3
}
4
4
5
- output "firehose_delivery_stream_arn" {
6
- description = " Firehose Delivery Stream ARN"
7
- value = " ${ aws_kinesis_firehose_delivery_stream . fraud_detection_firehose_stream . arn } "
8
- }
9
-
10
- output "firehoseDeliveryRoleArn" {
11
- description = " Firehose Delivery Role ARN"
12
- value = " ${ aws_iam_role . fraud_detection_firehose_role . arn } "
13
- }
Original file line number Diff line number Diff line change
1
+ resource "aws_s3_bucket" "fraud_detection_function_bucket" {
2
+ bucket = " ${ var . function_bucket_name } -${ var . aws_region } "
3
+ acl = " private"
4
+
5
+ server_side_encryption_configuration {
6
+ rule {
7
+ apply_server_side_encryption_by_default {
8
+ sse_algorithm = " AES256"
9
+ }
10
+ }
11
+ }
12
+
13
+ tags = {
14
+ Description = " Bucket hosting the code for fraud_detection Lambda function."
15
+ Group = var.default_resource_group
16
+ CreatedBy = var.default_created_by
17
+ }
18
+ }
19
+
20
+ data "archive_file" "fraud_detection_archive" {
21
+ type = " zip"
22
+ source_file = " ${ path . module } /../source/fraud_detection/index.py"
23
+ output_path = " ${ path . module } /../dist/fraud_detection.zip"
24
+ }
25
+
26
+ resource "aws_s3_bucket_object" "s3_fraud_detection_archive" {
27
+ bucket = aws_s3_bucket. fraud_detection_function_bucket . id
28
+ key = " fraud-detection-using-machine-learning/${ var . function_version } /fraud_detection.zip"
29
+ source = data. archive_file . fraud_detection_archive . output_path
30
+
31
+ # The filemd5() function is available in Terraform 0.11.12 and later
32
+ # For Terraform 0.11.11 and earlier, use the md5() function and the file() function:
33
+ # etag = "${md5(file("path/to/file"))}"
34
+ etag = filemd5 (data. archive_file . fraud_detection_archive . output_path ) # use md5 of index.py to detect changes in the function
35
+ }
You can’t perform that action at this time.
0 commit comments