Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The AWS Access Key Id you provided does not exist in our records #10756

Closed
1 task done
VSVDEv opened this issue May 1, 2024 · 3 comments
Closed
1 task done

The AWS Access Key Id you provided does not exist in our records #10756

VSVDEv opened this issue May 1, 2024 · 3 comments
Labels
area: configuration Configuring LocalStack status: backlog Triaged but not yet being worked on type: bug Bug report

Comments

@VSVDEv
Copy link

VSVDEv commented May 1, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Here is a docker-compose.yaml
`version: "3.8"

services:
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
image: localstack/localstack
ports:
- "127.0.0.1:4566:4566" # LocalStack Gateway
- "127.0.0.1:4510-4559:4510-4559" # external services port range
environment:
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
- DEBUG=${DEBUG:-0}
# - AWS_REGION=eu-west-2
- AWS_ACCESS_KEY_ID=1
- AWS_SECRET_ACCESS_KEY=1
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"`

I deploy lambda to localstack and try to get s3 object in java code but got an error

`
public class App implements RequestHandler<S3Event, String> {

 AmazonS3 s3 ;
private static final String WORD_BREAK = "\\W+";

Gson gson = new GsonBuilder().setPrettyPrinting()
.excludeFieldsWithoutExposeAnnotation()
.create();

public App() {

    String accesskey = System.getenv("AWS_ACCESS_KEY_ID");
    String secret = System.getenv("AWS_SECRET_ACCESS_KEY");
    String endpoint = System.getenv("AWS_ENDPOINT_URL");
    ClientConfiguration config = new ClientConfiguration();
    config.setProtocol(Protocol.HTTP);
    s3 = new AmazonS3Client(new BasicAWSCredentials(accesskey, secret), config);
    S3ClientOptions options =  new S3ClientOptions();
    options.setPathStyleAccess(true);
    s3.setS3ClientOptions(options);
    s3.setEndpoint(endpoint);


}

@Override
public String handleRequest(S3Event event, Context context) {

    LambdaLogger logger = context.getLogger();
    logger.log("*************************************************************************************** ");
    logger.log("Client: " + gson.toJson(s3));
    logger.log("*************************************************************************************** ");
    logger.log("ENVIRONMENT VARIABLES: " + gson.toJson(System.getenv()));
    S3EventNotification.S3EventNotificationRecord record = event.getRecords().get(0);

    String bucketName = record.getS3().getBucket().getName();
    String fileName = record.getS3().getObject().getKey() + ".txt";

    logger.log("bucket name: " + gson.toJson(bucketName));
    logger.log("file name: " + gson.toJson(fileName));


    String input = getFileFromS3(fileName, bucketName);
    Set<String> uniqueWords;
    if (input.length() > 0) {
        uniqueWords = processString(input);
    } else {
        logger.log("Error: Input is empty ");
        throw new RuntimeException("Input is empty");
    }

    logger.log("set: " + gson.toJson(uniqueWords));`

Here is log aws lambda invoke --function-name s3-Storage-14087538 --cli-binary-format raw-in-base64-out --payload file://s3.json --profile st out --log-type Tail --query 'LogResult' --output text --cli-binary-format raw-in-base64-out | base64 --decode START RequestId: 3c2fbbac-2d59-438b-b932-9ba226f4f9bd Version: $LATEST *************************************************************************************** Client: {}*************************************************************************************** ENVIRONMENT VARIABLES: { "PATH": "/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin", "_AWS_XRAY_DAEMON_ADDRESS": "127.0.0.1", "LAMBDA_TASK_ROOT": "/var/task", "AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "512", "TZ": ":UTC", "AWS_SECRET_ACCESS_KEY": "1", "AWS_EXECUTION_ENV": "AWS_Lambda_java17", "AWS_DEFAULT_REGION": "us-east-1", "AWS_LAMBDA_LOG_GROUP_NAME": "/aws/lambda/s3-Storage-14087538", "_HANDLER": "vsvdev.App::handleRequest", "LANG": "en_US.UTF-8", "LAMBDA_RUNTIME_DIR": "/var/runtime", "AWS_SESSION_TOKEN": "FQoGZXIvYXdzEBYaDmCnYve+fO7VCvI86oywQLDi8P19FubBKwdGD+LaJ2EbpXs1htIHT6UC5ZSIX+qgyVjEciTnfrcqNh5gZrJLVcK51RXzS2z0gVoAUwi0HaRIDLUeU1N8zg8Bx3DiWxgqnlLhpAxP8DsUjaBDZiMztdzPM7g2JGOyvctcQ6Ii5aANYzjPDVYToAkILcMI6/Z++igA++QXBZDeirhZsTJn4NRpJz2md7l4W4PcS4gCwdC0dkV+eHr2+frGHxH0IkHwMdKk8OvtgljKciAeR2wG7Mjezk+oVgPqAwXjVwBSB+9C09zIrEU2gD6PGP+3fbIPMBwEwDGkvbrc+ISozSk\u003d", "AWS_ACCESS_KEY_ID": "1", "LD_LIBRARY_PATH": "/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib", "AWS_LAMBDA_RUNTIME_API": "127.0.0.1:9001", "AWS_REGION": "us-east-1", "AWS_LAMBDA_FUNCTION_TIMEOUT": "3", "AWS_ENDPOINT_URL": "http://localhost:4566", "AWS_LAMBDA_LOG_STREAM_NAME": "2024/05/01/[$LATEST]772baeb523efe5029239d8331c7eb3f3", "AWS_LAMBDA_INITIALIZATION_TYPE": "on-demand", "SOURCE_BUCKET": "sourceconfigbckt", "AWS_XRAY_DAEMON_ADDRESS": "127.0.0.1:2000", "_AWS_XRAY_DAEMON_PORT": "2000", "AWS_XRAY_CONTEXT_MISSING": "LOG_ERROR", "EDGE_PORT": "4566", "AWS_CONTAINER_AUTHORIZATION_TOKEN": "36b2c8fb-47af-4087-9717-fb18ae67a630", "AWS_LAMBDA_FUNCTION_VERSION": "$LATEST", "LOCALSTACK_HOSTNAME": "172.18.0.2", "AWS_LAMBDA_FUNCTION_NAME": "s3-Storage-14087538", "AWS_CONTAINER_CREDENTIALS_FULL_URI": "http://127.0.0.1:9001/2021-04-23/credentials" }bucket name: "vsvdevsource"file name: "test2.txt"Exception herecom.amazonaws.services.s3.model.AmazonS3Exception: The AWS Access Key Id you provided does not exist in our records. (Service: Amazon S3; Status Code: 403; Error Code: InvalidAccessKeyId; Request ID: E9Q5T9116R8GHMWQ; S3 Extended Request ID: lsk3gtK5tFm4zZMqX6+8kw/jAS1vjAd1J9GDNurrmYmq/sb+x3hoV1cCXdEDwFisQsICMRBlDN8=; Proxy: null), S3 Extended Request ID: lsk3gtK5tFm4zZMqX6+8kw/jAS1vjAd1J9GDNurrmYmq/sb+x3hoV1cCXdEDwFisQsICMRBlDN8= Error: Input is empty Input is empty: java.lang.RuntimeException
I also tried use it without endpoint

`String accesskey = System.getenv("AWS_ACCESS_KEY_ID");
String secret = System.getenv("AWS_SECRET_ACCESS_KEY");
ClientConfiguration config = new ClientConfiguration();
config.setProtocol(Protocol.HTTP);
s3 = new AmazonS3Client(new BasicAWSCredentials(accesskey, secret), config);
S3ClientOptions options = new S3ClientOptions();
options.setPathStyleAccess(true);

And also my deployed function { "Functions": [ { "FunctionName": "s3-Storage-14087538", "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:s3-Storage-14087538", "Runtime": "java17", "Role": "arn:aws:iam::000000000000:role/s3-StorageRole-d5ff3508", "Handler": "vsvdev.App::handleRequest", "CodeSize": 7055211, "Description": "", "Timeout": 3, "MemorySize": 512, "LastModified": "2024-05-01T09:28:27.151207+0000", "CodeSha256": "Pyt4/ojnmRJTO344BMUh+lOOlbLBh2ZmEKqZVxdHHO0=", "Version": "$LATEST", "Environment": { "Variables": { "SOURCE_BUCKET": "sourceconfigbckt", "AWS_ACCESS_KEY_ID": "1", "AWS_SECRET_ACCESS_KEY": "1", "AWS_ENDPOINT_URL": "http://localhost:4566" } }, "TracingConfig": { "Mode": "PassThrough" }, "RevisionId": "0a87b6ac-fa4e-4d9d-aa92-f11d2e2ff437", "PackageType": "Zip", "Architectures": [

Expected Behavior

works without errors

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

run localstack: docker compose up

create lambda which read from s3 based on event.
put object to s3
Triger function

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

[profile st]
region = us-east-1
output = json
endpoint_url = http://localhost:4566

sam build

sam deploy --guided --profile st

aws lambda list-function --profile st

aws s3 ls --profile st

aws s3api put-object --bucket vsvdevsource --key test2.txt --body test2.txt --profile st

aws s3api list-objects --bucket vsvdevsource --profile st

aws s3api list-objects --bucket vsvdevdestination --profile st

aws s3api create-bucket --bucket sample --profile st

sam local generate-event s3 put --bucket vsvdevsource > events/s3.json

aws lambda invoke --invocation-type Event --function-name Storage --cli-binary-format raw-in-base64-out --payload file://s3.json --profile st out.txt

aws lambda list-functions --profile st

aws lambda invoke --function-name s3-Storage-14087538 --cli-binary-format raw-in-base64-out --payload file://s3.json --profile st out --log-type Tail --query 'LogResult' --output text --cli-binary-format raw-in-base64-out | base64 --decode

Environment

- OS: windows 10
- LocalStack: latest 1 May 2024

Anything else?

No response

@VSVDEv VSVDEv added status: triage needed Requires evaluation by maintainers type: bug Bug report labels May 1, 2024
@localstack-bot
Copy link
Collaborator

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.

@MarcelStranak MarcelStranak added status: backlog Triaged but not yet being worked on area: configuration Configuring LocalStack and removed status: triage needed Requires evaluation by maintainers labels May 8, 2024
@MarcelStranak
Copy link

Hello @VSVDEv,

I would like to provide some steps if they can resolve the issue.

Change your docker-compose.yml

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
    environment:
      # LocalStack configuration: https://docs.localstack.cloud/references/configuration/
      - DEBUG=${DEBUG:-0}
      - AWS_ACCESS_KEY_ID=test
      - AWS_SECRET_ACCESS_KEY=test
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

Use samlocal a wrapper for the AWS SAM CLI.`
Docs: https://docs.localstack.cloud/user-guide/integrations/aws-sam/

For the Java SDK, Please follow the steps mentioned in https://docs.localstack.cloud/user-guide/integrations/sdks/java/

@VSVDEv
Copy link
Author

VSVDEv commented May 23, 2024

Thank you for your assistance!

@VSVDEv VSVDEv closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: configuration Configuring LocalStack status: backlog Triaged but not yet being worked on type: bug Bug report
Projects
None yet
Development

No branches or pull requests

3 participants