Skip to content

Commit

Permalink
STS: add support for signing requests with assume_role tokens (#117)
Browse files Browse the repository at this point in the history
* Aws_gen: add additional_libraries field to dune gen
* Sts_test: add assume_role and token authentication tests

Co-authored-by: Adam Ringwood <[email protected]>
Co-authored-by: Leon Chou <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2021
1 parent 876bdb4 commit 4acdbcd
Show file tree
Hide file tree
Showing 51 changed files with 265 additions and 92 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
----------
- Increase lower bound on OCaml to 4.08. https://github.com/inhabitedtype/ocaml-aws/pull/104
- Migrate CI to github actions https://github.com/inhabitedtype/ocaml-aws/pull/104
- Add STS `assume_role` token support https://github.com/inhabitedtype/ocaml-aws/pull/117

1.2: (24-01-2020)
----------
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ clean:
rm -rf _build *.install

fmt:
dune build @fmt --auto-promote
dune build @fmt --auto-promote || echo "format has errors, ignoring"

.PHONY: endpoints

Expand All @@ -26,9 +26,11 @@ endpoints:
aws-ec2:
dune exec aws-gen -- --is-ec2 -i input/ec2/latest/service-2.json -r input/ec2/overrides.json -e input/errors.json -o libraries

aws-autoscaling:
dune exec aws-gen -- -i input/autoscaling/latest/service-2.json -r input/autoscaling/overrides.json -e input/errors.json -o libraries --optional-libs=aws-ec2

# NOTE: This does not include aws-ec2, which is special-cased.
LIBRARIES := \
aws-autoscaling \
aws-cloudformation \
aws-cloudtrail \
aws-cloudwatch \
Expand All @@ -45,7 +47,7 @@ LIBRARIES := \
$(LIBRARIES): aws-%:
dune exec aws-gen -- -i input/$*/latest/service-2.json -r input/$*/overrides.json -e input/errors.json -o libraries

gen: build aws-ec2 $(LIBRARIES)
gen: build aws-ec2 aws-autoscaling $(LIBRARIES) fmt

update-version: VERSION=$(shell cat CHANGES.md | grep -E '^[0-9]' | head -n 1 | cut -f1 -d':' )
update-version:
Expand Down
3 changes: 3 additions & 0 deletions async/runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ let run_request
~region
~access_key
~secret_key
?token
(module M : Aws.Call
with type input = input
and type output = output
Expand All @@ -55,13 +56,15 @@ let run_request
Aws.Signing.sign_request
~access_key
~secret_key
?token
~service:M.service
~region
(M.to_http M.service region inp)
| V2 ->
Aws.Signing.sign_v2_request
~access_key
~secret_key
?token
~service:M.service
~region
(M.to_http M.service region inp)
Expand Down
4 changes: 3 additions & 1 deletion async/runtime.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ val run_request :
region:string
-> access_key:string
-> secret_key:string
-> ?token:string
-> ('input, 'output, 'error) Aws.call
-> 'input
-> [ `Ok of 'output | `Error of 'error Aws.Error.t ] Async.Deferred.t
(** Run an AWS request, in the [region] with [access_key] and [secret_key]. *)
(** Run an AWS request, in the [region] with [access_key] and [secret_key].
* An STS assume_role [token] can be optionally used to sign the request. *)
11 changes: 6 additions & 5 deletions aws-autoscaling.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Auto Scaling"
description: "Amazon Web Services SDK bindings to Auto Scaling"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [ "Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
"aws" {= version}
Expand Down
6 changes: 3 additions & 3 deletions aws-cloudformation.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to AWS CloudFormation"
description: "Amazon Web Services SDK bindings to AWS CloudFormation"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-cloudtrail.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to AWS CloudTrail"
description: "Amazon Web Services SDK bindings to AWS CloudTrail"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-cloudwatch.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Amazon CloudWatch"
description: "Amazon Web Services SDK bindings to Amazon CloudWatch"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-ec2.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Amazon Elastic Compute Cloud"
description: "Amazon Web Services SDK bindings to Amazon Elastic Compute Cloud"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-elasticache.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Amazon ElastiCache"
description: "Amazon Web Services SDK bindings to Amazon ElastiCache"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-elasticloadbalancing.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Elastic Load Balancing"
description: "Amazon Web Services SDK bindings to Elastic Load Balancing"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
1 change: 1 addition & 0 deletions aws-gen.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ depends: [
"yojson"
"base-unix"
"cmdliner"
"fmt"
"ppx_tools_versioned"
"yojson" {>= "1.6.0"}
"ocaml-migrate-parsetree"
Expand Down
12 changes: 5 additions & 7 deletions aws-rds.opam
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
opam-version: "2.0"
version: "1.2"
synopsis:
"Amazon Web Services SDK bindings to Amazon Relational Database Service"
description:
"Amazon Web Services SDK bindings to Amazon Relational Database Service"
synopsis: "Amazon Web Services SDK bindings to Amazon Relational Database Service"
description: "Amazon Web Services SDK bindings to Amazon Relational Database Service"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -30,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-route53.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Amazon Route 53"
description: "Amazon Web Services SDK bindings to Amazon Route 53"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
6 changes: 3 additions & 3 deletions aws-sdb.opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Amazon SimpleDB"
description: "Amazon Web Services SDK bindings to Amazon SimpleDB"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -28,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
9 changes: 4 additions & 5 deletions aws-sqs.opam
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
opam-version: "2.0"
version: "1.2"
synopsis: "Amazon Web Services SDK bindings to Amazon Simple Queue Service"
description:
"Amazon Web Services SDK bindings to Amazon Simple Queue Service"
description: "Amazon Web Services SDK bindings to Amazon Simple Queue Service"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -29,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
12 changes: 5 additions & 7 deletions aws-ssm.opam
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
opam-version: "2.0"
version: "1.2"
synopsis:
"Amazon Web Services SDK bindings to Amazon Simple Systems Management Service"
description:
"Amazon Web Services SDK bindings to Amazon Simple Systems Management Service"
synopsis: "Amazon Web Services SDK bindings to Amazon Simple Systems Management Service"
description: "Amazon Web Services SDK bindings to Amazon Simple Systems Management Service"
maintainer: "Tim McGilchrist <[email protected]>"
authors: [
authors: [
"Spiros Eliopoulos <[email protected]>"
"Daniel Patterson <[email protected]>"
"Tim McGilchrist <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/ocaml-aws"
doc: "https://github.com/inhabitedtype/ocaml-aws"
bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
doc: "https://github.com/inhabitedtype/ocaml-aws"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
Expand All @@ -30,4 +28,4 @@ depends: [
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
]
Loading

0 comments on commit 4acdbcd

Please sign in to comment.