levoai / aws-cloudfront-lambda

Levo's Lambda@Edge function to ingest traffic from AWS CloudFront distributions.
0 stars 0 forks source link

Error in running install.sh #6

Open banro21 opened 9 months ago

banro21 commented 9 months ago
rohitbansal_iomd@testadmins-MacBook-Pro aws-cloudfront-lambda % ./install.sh                                           
Adding the lambda code to a zip file...
sed: 1: "src/index.mjs": unterminated substitute pattern
  adding: index.mjs (deflated 62%)
sed: 1: "src/index.mjs": unterminated substitute pattern

Creating a role for the lambda functions...
{
    "Role": {
        "Path": "/",
        "RoleName": "levoCloudFrontLambdaRole",
        "RoleId": "AROATJ5TMARJQB2FK5NOP",
        "Arn": "arn:aws:iam::227472573523:role/levoCloudFrontLambdaRole",
        "CreateDate": "2024-01-10T00:46:13+00:00",
        "AssumeRolePolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Principal": {
                        "Service": [
                            "lambda.amazonaws.com",
                            "edgelambda.amazonaws.com"
                        ]
                    },
                    "Action": "sts:AssumeRole"
                }
            ]
        }
    }
}

Creating lambda functions...

An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: The role defined for the function cannot be assumed by Lambda.
{
    "FunctionName": "levoResponseHandler",
    "FunctionArn": "arn:aws:lambda:us-east-1:227472573523:function:levoResponseHandler",
    "Runtime": "nodejs20.x",
    "Role": "arn:aws:iam::227472573523:role/levoCloudFrontLambdaRole",
    "Handler": "index.responseHandler",
    "CodeSize": 796,
    "Description": "",
    "Timeout": 10,
    "MemorySize": 128,
    "LastModified": "2024-01-10T00:46:21.139+0000",
    "CodeSha256": "jP3bKQ/CF/2rMMvFhX2sLE31PeliU7HNyyuDhj2O6Vg=",
    "Version": "$LATEST",
    "TracingConfig": {
        "Mode": "PassThrough"
    },
    "RevisionId": "994a9718-f17a-49c1-ba1a-0a9aac58ad69",
    "State": "Pending",
    "StateReason": "The function is being created.",
    "StateReasonCode": "Creating",
    "PackageType": "Zip",
    "Architectures": [
        "x86_64"
    ],
    "EphemeralStorage": {
        "Size": 512
    },
    "SnapStart": {
        "ApplyOn": "None",
        "OptimizationStatus": "Off"
    },
    "RuntimeVersionConfig": {
        "RuntimeVersionArn": "arn:aws:lambda:us-east-1::runtime:0593533e3a90a967b5685780855b7a89f7ba80b7d910603abf59369c6c4c7331"
    }
}
Publishing the lambda functions...

An error occurred (ResourceNotFoundException) when calling the PublishVersion operation: Function not found: arn:aws:lambda:us-east-1:227472573523:function:levoRequestHandler
{
    "FunctionName": "levoResponseHandler",
    "FunctionArn": "arn:aws:lambda:us-east-1:227472573523:function:levoResponseHandler:1",
    "Runtime": "nodejs20.x",
    "Role": "arn:aws:iam::227472573523:role/levoCloudFrontLambdaRole",
    "Handler": "index.responseHandler",
    "CodeSize": 796,
    "Description": "",
    "Timeout": 10,
    "MemorySize": 128,
    "LastModified": "2024-01-10T00:46:21.139+0000",
    "CodeSha256": "jP3bKQ/CF/2rMMvFhX2sLE31PeliU7HNyyuDhj2O6Vg=",
    "Version": "1",
    "TracingConfig": {
        "Mode": "PassThrough"
    },
    "RevisionId": "6e770895-4cb7-4332-825c-eb41d3ec04f4",
    "State": "Active",
    "LastUpdateStatus": "Successful",
    "PackageType": "Zip",
    "Architectures": [
        "x86_64"
    ],
    "EphemeralStorage": {
        "Size": 512
    },
    "SnapStart": {
        "ApplyOn": "None",
        "OptimizationStatus": "Off"
    },
    "RuntimeVersionConfig": {
        "RuntimeVersionArn": "arn:aws:lambda:us-east-1::runtime:0593533e3a90a967b5685780855b7a89f7ba80b7d910603abf59369c6c4c7331"
    }
}

Deleting the zip file...

An error occurred (ResourceNotFoundException) when calling the ListVersionsByFunction operation: Function not found: arn:aws:lambda:us-east-1:227472573523:function:levoRequestHandler
########## READ ME! ##########

Please note the values below and follow further instructions at https://github.com/levoai/aws-cloudfront-lambda.

Request Handler ARN

Response Handler ARN
arn:aws:lambda:us-east-1:227472573523:function:levoResponseHandler:1

##############################
Done!
banro21 commented 9 months ago
-sed -i "s/LEVO_ORG_ID/$LEVO_ORG_ID/g" src/index.mjs
+sed -i "" "s/LEVO_ORG_ID/$LEVO_ORG_ID/g" src/index.mjs
banro21 commented 9 months ago

probably related to macOS. I also had to switch to bash for making the script run