Class AWS

AWS class.

Methods

aws:new (config) Creates a new AWS instance.


Methods

aws:new (config)
Creates a new AWS instance. By default the instance will get a CredentialProviderChain set of credentials, which can be overridden.

Note that the AWS objects as well as the Service objects are expensive to create, so you might want to reuse them.

Parameters:

  • config (optional) the config table to be copied into the instance as the global aws_instance.config

Usage:

  • -- in the "init" phase initialize the configuration
    local _ = require("resty.aws.config").global
  • -- In your code
    local AWS = require("resty.aws")
    local AWS_global_config = require("resty.aws.config").global
    
    local config = { region = AWS_global_config.region }
    
    local aws = AWS(config)
    
    -- Override default "CredentialProviderChain" credentials.
    -- This is optional, the defaults should work with AWS-IAM.
    local my_creds = aws:Credentials {
      accessKeyId = "access",
      secretAccessKey = "secret",
      sessionToken = "token",
    }
    aws.config.credentials = my_creds
    
    -- instantiate a service (optionally overriding the aws-instance config)
    local sm = aws:SecretsManager {
      region = "us-east-2",
    }
    
    -- Invoke a method.
    -- Note this only takes the parameter table, and NOT a callback as the
    -- JS sdk requires. Instead this call will directly return the results.
    local results, err = sm:getSecretValue {
      SecretId = "arn:aws:secretsmanager:us-east-2:238406704566:secret:test-HN1F1k",
    }
generated by LDoc 1.5.0 Last updated 2024-09-23 09:29:37