diff --git a/local_testing/delete_infra.sh b/local_testing/delete_infra.sh new file mode 100755 index 0000000..1a99f72 --- /dev/null +++ b/local_testing/delete_infra.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Variables +REGION="us-west-2" # Preferred AWS region + +runtimes=("python3.11" "python3.12") +architectures=("x86_64" "arm64") + +for arch in "${architectures[@]}"; do + for runtime in "${runtimes[@]}"; do + FUNCTION_NAME_SUFFIX="${arch}_${runtime//./}" + FUNCTION_NAME="NR_EXTENSION_TEST_LAMBDA_${FUNCTION_NAME_SUFFIX}" + if aws lambda delete-function --function-name "$FUNCTION_NAME" --region "$REGION"; then + echo "Successfully deleted $FUNCTION_NAME" + else + echo "Failed to delete $FUNCTION_NAME" + fi + done +done diff --git a/local_testing/environment.json b/local_testing/environment.json new file mode 100644 index 0000000..c3015d5 --- /dev/null +++ b/local_testing/environment.json @@ -0,0 +1,11 @@ +{ + "Variables": { + "NEW_RELIC_ACCOUNT_ID": "", + "NEW_RELIC_EXTENSION_SEND_FUNCTION_LOGS": "", + "NEW_RELIC_LAMBDA_EXTENSION_ENABLED": "", + "NEW_RELIC_LAMBDA_HANDLER": "lambda_function.lambda_handler", + "NEW_RELIC_LICENSE_KEY": "", + "NEW_RELIC_LOG_ENDPOINT": "", + "NEW_RELIC_TELEMETRY_ENDPOINT": "" + } +} diff --git a/local_testing/test.sh b/local_testing/test.sh index f15cd51..6c50a47 100755 --- a/local_testing/test.sh +++ b/local_testing/test.sh @@ -7,20 +7,13 @@ REGION="us-west-2" # Preferred AWS region TRUST_POLICY="trust-policy.json" lambda_result_file="lambda_output.txt" -NEW_RELIC_ACCOUNT_ID="${NEW_RELIC_ACCOUNT_ID}" -NEW_RELIC_LAMBDA_EXTENSION_ENABLED="True" -NEW_RELIC_LAMBDA_HANDLER="${NEW_RELIC_LAMBDA_HANDLER}" -NEW_RELIC_LICENSE_KEY_SECRET="${NEW_RELIC_LICENSE_KEY_SECRET}" -NEW_RELIC_LOG_ENDPOINT="${NEW_RELIC_LOG_ENDPOINT}" -NEW_RELIC_TELEMETRY_ENDPOINT="${NEW_RELIC_TELEMETRY_ENDPOINT}" - source nr_tmp_env.sh zip function.zip function.py role_exists=$(aws iam get-role --role-name "$ROLE_NAME" --query 'Role.Arn' --output text --region "$REGION" 2>&1) if [[ $role_exists == arn:aws:iam::* ]]; then - echo "IAM role already exists." + echo "IAM role $ROLE_NAME already exists." EXECUTION_ROLE_ARN=$role_exists else EXECUTION_ROLE_ARN=$(aws iam create-role --role-name "$ROLE_NAME" --assume-role-policy-document "file://$TRUST_POLICY" --query 'Role.Arn' --output text --region "$REGION") @@ -65,7 +58,7 @@ for arch in "${architectures[@]}"; do --architectures "$arch" \ --role "$EXECUTION_ROLE_ARN" \ --layers "$final_layer_arn" \ - --environment Variables="{NEW_RELIC_ACCOUNT_ID=$NEW_RELIC_ACCOUNT_ID,NEW_RELIC_LAMBDA_EXTENSION_ENABLED=$NEW_RELIC_LAMBDA_EXTENSION_ENABLED,NEW_RELIC_LAMBDA_HANDLER=$NEW_RELIC_LAMBDA_HANDLER,NEW_RELIC_LICENSE_KEY_SECRET=$NEW_RELIC_LICENSE_KEY_SECRET,NEW_RELIC_LOG_ENDPOINT=$NEW_RELIC_LOG_ENDPOINT,NEW_RELIC_TELEMETRY_ENDPOINT=$NEW_RELIC_TELEMETRY_ENDPOINT}" \ + --environment file://environment.json \ --query 'FunctionArn' \ --output text \ --region "$REGION")