terradart_aws 0.36.0
terradart_aws: ^0.36.0 copied to clipboard
Curated factory wrappers for AWS resources (hashicorp/aws Terraform provider) for Dart-first Terraform stacks.
terradart_aws #
Curated factory wrappers for AWS resources (the hashicorp/aws Terraform provider) for Dart-first Terraform stacks.
The catalog is the full hashicorp/aws provider at its exact pin: every resource and data source. Start from a Dart backend on AWS Lambda: an execution role, a managed-policy attachment, the function, a function URL, and a log group, plus the aws_iam_policy_document and aws_caller_identity data sources.
Security & Credentials #
Credentials never appear in synth output by design. The AWS provider schema does not mark its credential arguments sensitive, so AwsProvider leaves them out by name: there is no access_key, secret_key, token, or assume_role_with_web_identity parameter. Authenticate at apply time through the AWS SDK credential chain: AWS_PROFILE with your shared config, AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN, or an instance or task role. assumeRole, defaultTags, ignoreTags and endpoints are typed settings on AwsProvider.
Installation #
dependencies:
terradart_core: ^0.36.0
terradart_aws: ^0.36.0
Usage example #
import 'package:terradart_aws/data.dart';
import 'package:terradart_aws/iam.dart';
import 'package:terradart_aws/lambda.dart';
import 'package:terradart_aws/provider.dart';
final class HelloStack extends Stack {
HelloStack()
: super(providers: [
const AwsProvider(
region: 'us-east-1',
defaultTags: {'app': 'hello-dart'},
),
]) {
final trust = DataAwsIamPolicyDocument(
'lambda_trust',
statement: [
DataIamPolicyDocumentStatement(
actions: .literal(['sts:AssumeRole']),
principals: [
.new(
type: .literal('Service'),
identifiers: .literal(['lambda.amazonaws.com']),
),
],
),
],
);
add(trust);
final role = AwsIamRole(
'hello',
assumeRolePolicy: trust.json,
);
add(role);
add(AwsLambdaFunction(
'hello',
functionName: .literal('hello-dart'),
role: role.ref,
runtime: .providedAl2023,
handler: .literal('bootstrap'),
code: .filename(.literal('build/bootstrap.zip')),
));
}
}
dart pub get
dart pub global activate terradart_cli
AWS_PROFILE=... terradart apply
Curated surface #
Every resource and data source of the pinned provider, across per-service barrels (ec2, iam, lambda, s3, rds, …) plus data. The provider is pinned exactly (kAwsProviderVersionConstraint, the release the wrappers were generated from). Start with examples/aws_lambda_quickstart, which builds the bootstrap zip from a Dart handler. examples/aws_serverless_api_quickstart is the full stack: that handler behind an API Gateway HTTP API and a DynamoDB table, with a least-privilege role and the API URL and table name read back through the generated outputs reader. examples/aws_static_site_quickstart hosts a Flutter Web build on S3 + CloudFront with a custom domain, and examples/aws_ecs_express_quickstart runs a Dart server on ECS Express Mode; both need real AWS setup to apply (their READMEs' "Before you apply"). The rest of the catalog is exercised by examples/aws_leftover_quickstart (synth only; CI validates it against the provider).
The six most deeply nested resources (AwsWafv2WebAcl, AwsWafv2WebAclRule, AwsWafv2RuleGroup, AwsQuicksightAnalysis, AwsQuicksightDashboard, AwsQuicksightTemplate) take typed nested helpers, but a block shape that repeats inside one resource gets one helper, named after its shallowest occurrence. The challengeConfig of an AwsWafv2WebAclRule therefore takes Wafv2WebAclRuleCaptchaConfig, and an asnMatchStatement nested inside andStatement levels takes the same Wafv2WebAclRuleAsnMatchStatement as a top-level one. The inline rule blocks on AwsWafv2WebAcl stay a TfArg<Map<String, dynamic>> map; manage rules through AwsWafv2WebAclRule for the typed form.
Generated by the maintainer pipeline (terradart-codegen wrap against the pin fixture); do not hand-edit files under lib/src/.