[][src]Module aws_arn::builder

Provides a more natural builder interface for constructing ARNs.

The builder pattern allows for a more readable construction of ARNs, and in this case we provide a number of verb prefixes on noun constructors, so we have in_region as well as and_region which is more readable if it is preceded by in_partition. For the account id field there is in_account, and_account, any_account, and owned_by; all of these accomplish the same goal but allow for a choice that makes code easir to understand.

Resource-Specific Constructor Functions

For the service-specific submodules (iam, lambda, s3, etc.) the functions are simply named for the noun that represents the resource type as described in the AWS documentation. As the partition in commonly left to default to "aws" there are also a set of {noun}_in() functions that take a partition, and corresponding {noun}() functions which do not.

In some cases where an ARN may be dependent on another, for example an S3 object ARN might be constructed from an existing bucket ARN, additional {noun}_from(other,...) functions will be provided.

Note that the final build() function will call validate(), and so it is possible to call intermediate functions with bad data which is only caught at build time.

Example

The following shows the construction of an AWS versioned layer ARN.

use aws_arn::builder::*;

let arn = ArnBuilder::new("lambda")
    .resource(
        ResourceBuilder::new("my-layer")
            .is_a("layer")
            .with_version(3)
            .build().unwrap(),
    )
    .in_region("us-east-2")
    .owned_by("123456789012")
    .build().expect("badly formatted ARN?");
println!("ARN: '{}'", arn);

This should print ARN: 'arn:aws:lambda:us-east-2:123456789012:layer:my-layer:3'.

Modules

cognito

Provides a set of simple helper functions to make ARNs for the Cognito Identity service.

iam

Provides a set of simple helper functions to make ARNs for the IAM service.

lambda

Provides a set of simple helper functions to make ARNs for the Lambda service.

s3

Provides a set of simple helper functions to make ARNs for the S3 service.

Structs

ArnBuilder

Builder type for an AWS ARN.

ResourceBuilder

Builder type for the resource portion of an ARN.