{"id":18546452,"url":"https://github.com/adroll/erliam","last_synced_at":"2025-04-09T20:30:54.623Z","repository":{"id":25789262,"uuid":"86761654","full_name":"AdRoll/erliam","owner":"AdRoll","description":"erlang library for caching credentials and signing AWS API requests","archived":false,"fork":false,"pushed_at":"2024-07-01T00:09:29.000Z","size":87,"stargazers_count":10,"open_issues_count":4,"forks_count":3,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-03-24T11:12:15.059Z","etag":null,"topics":["aws","erlang","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdRoll.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-31T00:30:49.000Z","updated_at":"2024-07-05T01:32:02.000Z","dependencies_parsed_at":"2024-11-06T20:32:38.520Z","dependency_job_id":"4469f0d3-c672-426c-8422-56e879676fd1","html_url":"https://github.com/AdRoll/erliam","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdRoll%2Ferliam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdRoll%2Ferliam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdRoll%2Ferliam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdRoll%2Ferliam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdRoll","download_url":"https://codeload.github.com/AdRoll/erliam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107180,"owners_count":21048873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","erlang","hacktoberfest"],"created_at":"2024-11-06T20:25:21.344Z","updated_at":"2025-04-09T20:30:54.274Z","avatar_url":"https://github.com/AdRoll.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# erliam\n\nerlang library for caching credentials and signing AWS API requests.\n\n## usage\n\n1. Add `erliam` to application dependencies or do `application:start(erliam)`.\n\n2. Call `erliam:credentials()` to obtain latest cached credentials (stored in ets and\nautomatically refreshed before expiry).\n\n3. Call `awsv4:headers(Credentials, Parameters)` to obtain awsv4-signed request headers to\nuse in AWS API calls.\n\nIf not using instance metadata, set `aws_access_key` and `aws_secret_key` in `erliam`\napplication environment to your long-term credentials; these will be used to obtain a\nsession token periodically.\n\n## example\n\n### Fetch an object from S3\n\n```\n\u003e application:start(erliam).\n\u003e QueryParams = #{\"prefix\" =\u003e \"some/prefix/\",\n                  \"delimiter\" =\u003e \"/\",\n                  \"list-type\" =\u003e \"2\",\n                  \"encoding-type\" =\u003e \"url\"}.\n\u003e Headers = awsv4:headers(erliam:credentials(),\n                          #{service =\u003e \"s3\",\n                            region =\u003e \"us-west-2\",\n                            host =\u003e \"bucketname.s3.amazonaws.com\",\n                            path =\u003e \"/\",\n                            query_params =\u003e QueryParams}).\n\u003e httpc:request(get, {lists:flatten(\"https://bucketname.s3.amazonaws.com/?\" ++\n                                    awsv4:canonical_query(QueryParams)), Headers}, [], []).\n\n{ok, {{\"HTTP/1.1\", 200, \"OK\"},\n [{\"date\", \"Fri, 02 Jun 2017 23:26:21 GMT\"},\n  {\"server\", \"AmazonS3\"},\n  {\"content-length\", \"496\"},\n  {\"content-type\", \"application/xml\"},\n  {\"x-amz-id-2\", \"SOME-ID\"},\n  {\"x-amz-request-id\", \"SOME-OTHER-ID\"},\n  {\"x-amz-bucket-region\", \"us-west-2\"}],\n \"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cListBucketResult xmlns=\\\"http://s3.amazonaws.com/doc/2006-03-01/\\\"\u003e\u003cName\u003ebucketname\u003c/Name\u003e...\"}}\n```\n\n### Encrypt plaintext using KMS\n\n```\n\u003e application:start(erliam).\n\u003e QueryParams = #{}.\n\u003e KeyId = \u003c\u003c\"xxxx-xxxx-xxxx-xxxx-xxxxxxxxxx\"\u003e\u003e\n\u003e RequestBody = jiffy:encode(#{\u003c\u003c\"EncryptionContext\"\u003e\u003e =\u003e #{\u003c\u003c\"application\"\u003e\u003e =\u003e \u003c\u003c\"thing encryptor\"\u003e\u003e},\n                               \u003c\u003c\"KeyId\"\u003e\u003e =\u003e KeyId,\n                               \u003c\u003c\"Plaintext\"\u003e\u003e =\u003e base64:encode(\u003c\u003c\"setec astronomy\"\u003e\u003e)}).\n\u003e SignedHeaders = #{\"content-type\" =\u003e \"application/x-amz-json-1.1\"}.\n\u003e Headers = awsv4:headers(erliam:credentials(),\n                          #{service =\u003e \"kms\",\n                            target_api =\u003e \"TrentService.Encrypt\",\n                            method =\u003e \"POST\",\n                            region =\u003e \"us-east-1\",\n                            query_params =\u003e QueryParams,\n                            signed_headers =\u003e SignedHeaders},\n                          RequestBody).\n\u003e httpc:request(post, {lists:flatten([\"https://kms.us-east-1.amazonaws.com\", \"/?\",\n                                      awsv4:canonical_query(QueryParams)]),\n                       Headers,\n                       proplists:get_value(\"content-type\", Headers), RequestBody}, [], []).\n\n{ok, {{\"HTTP/1.1\", 200, \"OK\"},\n     [{\"content-length\", \"307\"},\n      {\"content-type\", \"application/x-amz-json-1.1\"},\n      {\"x-amzn-requestid\", \"xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx\"}],\n     \"{\\\"CiphertextBlob\\\":\\\"B64ENCODED CIPHERTEXT\\\",\\\"KeyId\\\":\\\"KEY ARN\\\"}\"}}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadroll%2Ferliam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadroll%2Ferliam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadroll%2Ferliam/lists"}