|
| 1 | +{ |
| 2 | + "Resources": { |
| 3 | + "KafkaEventsFunction": { |
| 4 | + "Properties": { |
| 5 | + "Code": { |
| 6 | + "S3Bucket": "sam-demo-bucket", |
| 7 | + "S3Key": "metricsConfig.zip" |
| 8 | + }, |
| 9 | + "Handler": "index.handler", |
| 10 | + "Role": { |
| 11 | + "Fn::GetAtt": [ |
| 12 | + "KafkaEventsFunctionRole", |
| 13 | + "Arn" |
| 14 | + ] |
| 15 | + }, |
| 16 | + "Runtime": "nodejs16.x", |
| 17 | + "Tags": [ |
| 18 | + { |
| 19 | + "Key": "lambda:createdBy", |
| 20 | + "Value": "SAM" |
| 21 | + } |
| 22 | + ] |
| 23 | + }, |
| 24 | + "Type": "AWS::Lambda::Function" |
| 25 | + }, |
| 26 | + "KafkaEventsFunctionMyKafkaCluster": { |
| 27 | + "Properties": { |
| 28 | + "FunctionName": { |
| 29 | + "Ref": "KafkaEventsFunction" |
| 30 | + }, |
| 31 | + "ProvisionedPollerConfig": { |
| 32 | + "MaximumPollers": 100, |
| 33 | + "MinimumPollers": 2 |
| 34 | + }, |
| 35 | + "SelfManagedEventSource": { |
| 36 | + "Endpoints": { |
| 37 | + "KafkaBootstrapServers": [ |
| 38 | + "abc.xyz.com:9092", |
| 39 | + "123.45.67.89:9096" |
| 40 | + ] |
| 41 | + } |
| 42 | + }, |
| 43 | + "SelfManagedKafkaEventSourceConfig": { |
| 44 | + "ConsumerGroupId": "consumergroup1" |
| 45 | + }, |
| 46 | + "SourceAccessConfigurations": [ |
| 47 | + { |
| 48 | + "Type": "SASL_SCRAM_512_AUTH", |
| 49 | + "URI": "arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c" |
| 50 | + }, |
| 51 | + { |
| 52 | + "Type": "VPC_SUBNET", |
| 53 | + "URI": "subnet:subnet-12345" |
| 54 | + }, |
| 55 | + { |
| 56 | + "Type": "VPC_SECURITY_GROUP", |
| 57 | + "URI": "security_group:sg-67890" |
| 58 | + } |
| 59 | + ], |
| 60 | + "StartingPosition": "AT_TIMESTAMP", |
| 61 | + "StartingPositionTimestamp": 1672560000, |
| 62 | + "Topics": [ |
| 63 | + "Topic1" |
| 64 | + ] |
| 65 | + }, |
| 66 | + "Type": "AWS::Lambda::EventSourceMapping" |
| 67 | + }, |
| 68 | + "KafkaEventsFunctionMyMskEvent": { |
| 69 | + "Properties": { |
| 70 | + "AmazonManagedKafkaEventSourceConfig": { |
| 71 | + "ConsumerGroupId": "consumergroup1" |
| 72 | + }, |
| 73 | + "EventSourceArn": { |
| 74 | + "Fn::Sub": "arn:aws:kafka:${AWS::Region}:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2" |
| 75 | + }, |
| 76 | + "FunctionName": { |
| 77 | + "Ref": "KafkaEventsFunction" |
| 78 | + }, |
| 79 | + "ProvisionedPollerConfig": { |
| 80 | + "MaximumPollers": 10, |
| 81 | + "MinimumPollers": 5 |
| 82 | + }, |
| 83 | + "StartingPosition": "LATEST", |
| 84 | + "Topics": [ |
| 85 | + "MyDummyTestTopic" |
| 86 | + ] |
| 87 | + }, |
| 88 | + "Type": "AWS::Lambda::EventSourceMapping" |
| 89 | + }, |
| 90 | + "KafkaEventsFunctionRole": { |
| 91 | + "Properties": { |
| 92 | + "AssumeRolePolicyDocument": { |
| 93 | + "Statement": [ |
| 94 | + { |
| 95 | + "Action": [ |
| 96 | + "sts:AssumeRole" |
| 97 | + ], |
| 98 | + "Effect": "Allow", |
| 99 | + "Principal": { |
| 100 | + "Service": [ |
| 101 | + "lambda.amazonaws.com" |
| 102 | + ] |
| 103 | + } |
| 104 | + } |
| 105 | + ], |
| 106 | + "Version": "2012-10-17" |
| 107 | + }, |
| 108 | + "ManagedPolicyArns": [ |
| 109 | + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", |
| 110 | + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole" |
| 111 | + ], |
| 112 | + "Policies": [ |
| 113 | + { |
| 114 | + "PolicyDocument": { |
| 115 | + "Statement": [ |
| 116 | + { |
| 117 | + "Action": [ |
| 118 | + "secretsmanager:GetSecretValue" |
| 119 | + ], |
| 120 | + "Effect": "Allow", |
| 121 | + "Resource": "arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c" |
| 122 | + }, |
| 123 | + { |
| 124 | + "Action": [ |
| 125 | + "ec2:CreateNetworkInterface", |
| 126 | + "ec2:DescribeNetworkInterfaces", |
| 127 | + "ec2:DeleteNetworkInterface", |
| 128 | + "ec2:DescribeVpcs", |
| 129 | + "ec2:DescribeSubnets", |
| 130 | + "ec2:DescribeSecurityGroups" |
| 131 | + ], |
| 132 | + "Effect": "Allow", |
| 133 | + "Resource": "*" |
| 134 | + } |
| 135 | + ], |
| 136 | + "Version": "2012-10-17" |
| 137 | + }, |
| 138 | + "PolicyName": "SelfManagedKafkaExecutionRolePolicy" |
| 139 | + } |
| 140 | + ], |
| 141 | + "Tags": [ |
| 142 | + { |
| 143 | + "Key": "lambda:createdBy", |
| 144 | + "Value": "SAM" |
| 145 | + } |
| 146 | + ] |
| 147 | + }, |
| 148 | + "Type": "AWS::IAM::Role" |
| 149 | + } |
| 150 | + } |
| 151 | +} |
0 commit comments