Crate aws-arn
Provides the types, builders, and other helpers to manipulate AWS Amazon Resource Name (ARN) strings.
The ARN is a key component of all AWS service APIs and yet nearly all client toolkits treat it simply as a string. While this may be a reasonable and expedient decision, it seems there might be a need to not only ensure correctness of ARNs with validators but also constructors that allow making these strings correclt in the first place.
ARN Types
This crate provides a number of levels of ARN manipulation, the first is the
direct construction of an ARN type using the core ResourceName,
Identifier, AccountIdentifier, and ResourceIdentifier types.
use ;
use ;
use FromStr;
let arn = ResourceName ;
In the example above, as we are defining a minimal ResourceName we could use one of the defined constructor functions.
use ;
use Service;
use FromStr;
let arn = aws;
Alternatively, using FromStr, you can parse an existing ARN string into an ARN value.
use ResourceName;
use FromStr;
let arn: ResourceName = "arn:aws:s3:::mythings/thing-1"
.parse
.expect;
Another approach is to use a more readable builder which also allows you to ignore those fields in the ARN you don't always need and uses a more fluent style of ARN construction.
45Muse ;
use ;
use ;
use FromStr;
let arn: ResourceName = service_id
.resource
.in_partition_id
.into;
Finally, it is possible to use resource-type specific functions that allow an even more direct and
simple construction (module aws_arn::builder::{service} - service builder functions, although
at this time there are few supported services.
use s3;
use Identifier;
use FromStr;
let arn = object;
For more, see the AWS documentation for Amazon Resource Name (ARN) documentation.
Optional Features
This crate has attempted to be as lean as possible, with a really minimal set of dependencies, we have include the following capabilities as optional features.
buildersadds the builder module. This feature is enabled by default, it also requires theknownfeature.knownadds a module containing enums for partitions, regions, and services. This feature is enabled by default.serde_supportadds derivedSerializeandDeserializeimplementations for theARNandResourcetypes. This feature is enabled by default.
Changes
Version 0.3.1
- Added unit tests for
AccountIdentifier.
Version 0.3.0
- Breaking Change: Renamed
ARNtoResourceName. - Breaking Change: Renamed
ArnErrortoError. - Added interface for common Identifier operations.
- Added variable expansion for
ResourceIdentifierandResourceName. - Added more unit tests.
Version 0.2.1
- Created a new
AccountIdentifiertype for the 12-digit value. constsfeature renamedknown.
Version 0.2.0
- Relaxed validation of identifiers and resource identifiers.
- Removed
Resourcetype which added a lot of the validation confusion. - Using new
IdentifierandResourceIdentifiertypes to construct correctARNvalues without the need for any external validation methods. - Replaced
ResourceBuilderwith one forResourceIdentifiervalues. - Removed
ext_validationfeature - Added
constsfeature - Placed
buildermodule into newbuildersfeature. - Added a lot more tests including an
examples.txtfile that is just a long list to be parsed. - Fixed Github issue-2.
Version 0.1.1
- Documentation additions and fixes, in both README and Rustdoc.
- Renamed service builder functions, added a parent/child pattern for s3.
- Added Serde feature.
- Made external validation optional.
Version 0.1.0
- Initial commit.
- Provides basic ARN type with
DisplayandFromStr. - Provides scaffolding for service-specific validation.
- Provides initial set of service builder,
make_{format}, functions for ARN construction.
TODO
- More tests!
- More service formats for validation.
- More service builder functions.