aws-arn: Types and optics for manipulating Amazon Resource Names (ARNs)

[ aws, bsd3, cloud, library ] [ Propose Tags ]

This library provides a type representing Amazon Resource Names (ARNs), and parsing/unparsing functions for them. The provided optics make it very convenient to rewrite parts of ARNs.

Start reading at the Network.AWS.ARN module, which defines the core data type and includes some examples.

The ARN type is not designed to be a 100% correct-by-construction representation of only valid ARNs; it is designed to be a lightweight way to destructure and reassemble ARNs to be used in place of string munging.

The library aims to provide additional parsers for destructuring the "resource" part of an ARN, but many are missing right now. PRs to add this support for more AWS resource types are especially welcome.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.2.0.0, 0.3.0.0, 0.3.1.0
Change log CHANGELOG.md
Dependencies base (>=4.12 && <4.17), deriving-compat (>=0.5.10 && <0.7), hashable (>=1.3.0.0 && <1.5), lens (>=4.18.1 && <5.2), text (>=1.2.3 && <1.3 || >=2.0 && <2.1) [details]
License BSD-3-Clause
Copyright Copyright (C) 2020-2021 Bellroy Pty Ltd
Author Bellroy Tech Team <haskell@bellroy.com>
Maintainer Bellroy Tech Team <haskell@bellroy.com>
Revised Revision 1 made by jack at 2022-03-01T23:48:18Z
Category AWS, Cloud
Bug tracker http://github.com/bellroy/aws-arn/issues
Source repo head: git clone https://github.com/bellroy/aws-arn.git
Uploaded by jack at 2021-12-16T03:43:17Z
Distributions NixOS:0.3.1.0
Downloads 516 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for aws-arn-0.1.0.1

[back to package description]

aws-arn

CI Status

This library provides a type representing Amazon Resource Names (ARNs), and parsing/unparsing functions for them. The provided optics make it very convenient to rewrite parts of ARNs.

Start reading at the Network.AWS.ARN module, which defines the core data type and includes some examples.

The ARN type is not designed to be a 100% correct-by-construction representation of only valid ARNs; it is designed to be a lightweight way to destructure and reassemble ARNs to be used in place of string munging.

The library aims to provide additional parsers for destructuring the "resource" part of an ARN, but many are missing right now. PRs to add this support for more AWS resource types are especially welcome.

Guide: adding a resource

Cribbing from an existing module (e.g., Network.AWS.ARN.Lambda) is probably the easiest way to start, but here is an explicit process to add a new resource:

  1. Create a module for the AWS service, if it doesn't already exist. Example: src/Network/AWS/ARN/Lambda.hs.

  2. Define a record Foo to represent the parsed resource part of an ARN, and derive (at least) Eq, Ord, Hashable, Show and Generic. Also generate lenses for its fields:

    data Function = Function
    { _fName :: Text,
      _fQualifier :: Maybe Text
    }
    deriving (Eq, Ord, Hashable, Show, Generic)
    
    $(makeLenses ''Function)
    
  3. Define toFoo and fromFoo functions that attempt to parse and unparse the resource part of the ARN:

    toFunction :: Text -> Maybe Function
    fromFunction :: Function -> Text
    

    Remark: While these names sound backwards compared to fromText and toText, it means we can have multiple parsing functions in a single service's module.

    Remark: If you need to write tests for these functions, the corresponding module should live at test/Network/AWS/ARN/SomeAWSService/Test.hs

  4. Define a _Foo Prism' that combines the parsing/unparsing functions above:

    _Function :: Prism' Text Function
    _Function = prism' fromFunction toFunction
    
  5. Add the records, its fields, its parsing/unparsing functions, and its optics to the service module's export list:

    module Network.AWS.ARN.Lambda
      ( -- * Functions
        Function (..),
        toFunction,
        fromFunction,
    
        -- ** Function Optics
        _Function,
        fName,
        fQualifier,
      )
    
  6. Test your work and make a PR.

Formatters

The formatters used in this repo are provided by shell.nix:

Regenerate CI

This repo uses haskell-ci, which is provided by shell.nix:

haskell-ci regenerate