TfArg<T> class
sealed
A Terraform argument: a Dart-side literal, a reference to another block's attribute (TfRef), a variable or a raw expression.
T is the Dart type the factory parameter accepts. Resource factories
accept TfArg<T> (or TfArg<T>?) for every settable field, so an
attribute getter fills one as is: pushEndpoint: api.uri.
Writing arguments
Pick the form by where the value comes from. The argument's type tells you which forms it takes, and a dot shorthand (.literal, .new, .providedAl2023) names the constructor of that type.
| The value is | Write | Example |
|---|---|---|
| known when you synth | .literal(...) |
functionName: .literal('hello') |
another resource of this Stack (a RefTo<R> input) |
its ref |
role: role.ref |
| one attribute of another block | its getter | assumeRolePolicy: trust.json |
a resource outside this Stack (a RefTo<R> input) |
.literal(id) |
zoneId: .literal('023e105f4ecef8ad9ca31a8372d0c353') |
| one of a fixed set (an enum) | the member | runtime: .providedAl2023 |
| one of several exclusive arguments (a sealed type) | the variant | code: .filename(.literal('build/fn.zip')) |
| a nested block | its helper class; .new(...) inside another block or a variant |
environment: LambdaFunctionEnvironment(...) |
| a Terraform variable | the handle variable<T>() returns |
memorySize: memory |
a variable in an enum or RefTo<R> input |
.arg(handle) |
runtime: .arg(runtimeName) |
a secret (a Sensitive<T> input) |
a sensitive variable, never a literal | value: .value(dbPassword) |
| a reference inside a literal list or map | the getter's .interpolation |
{'ROLE_ARN': role.arn.interpolation} |
| anything else Terraform evaluates | .expression(...) |
.expression(r'${file("trust.json")}') |
final memory = variable<num>('memory_mb');
final runtimeName = variable<String>('runtime');
final dbPassword = variable<String>('db_password', sensitive: true);
final trust = add(
DataAwsIamPolicyDocument(
'trust',
statement: [
DataIamPolicyDocumentStatement(
actions: .literal(['sts:AssumeRole']),
principals: [
.new(
type: .literal('Service'),
identifiers: .literal(['lambda.amazonaws.com']),
),
],
),
],
),
);
final role = add(AwsIamRole('hello', assumeRolePolicy: trust.json));
add(
AwsLambdaFunction(
'hello',
functionName: .literal('hello'),
role: role.ref,
runtime: .arg(runtimeName),
code: .filename(.literal('build/fn.zip')),
memorySize: memory,
environment: LambdaFunctionEnvironment(
variables: .literal({'ROLE_ARN': role.arn.interpolation}),
),
),
);
add(
AwsSsmParameter(
'db_password',
name: .literal('/hello/db_password'),
type: .securestring,
value: .value(dbPassword),
),
);
- Implementers
- ArtifactRegistryVpcscConfigVpcscPolicy
- BigqueryAnalyticsHubDataExchangeSubscriptionRefreshPolicy
- CesSecuritySettingsEnforcementScope
- ComputeFutureReservationCommitmentPlan
- ComputeFutureReservationDeploymentType
- ComputeFutureReservationInterface
- ComputeFutureReservationMaintenanceInterval
- ComputeFutureReservationMode
- ComputeFutureReservationPlanningStatus
- ComputeFutureReservationPreviousCommitmentTerms
- ComputeFutureReservationSchedulingType
- ComputeFutureReservationShareType
- ComputeFutureReservationVmFamily
- ComputeFutureReservationWorkloadType
- ComputeInstanceFromMachineImageNicType
- ComputeInstanceFromMachineImageTotalEgressBandwidthTier
- ComputeNetworkFirewallPolicyPacketMirroringRuleDirection
- ComputeRegionBackendBucketLoadBalancingScheme
- ComputeRegionNetworkPolicyTrafficClassificationRuleDscpMode
- ComputeRegionNetworkPolicyTrafficClassificationRuleTrafficClass
- ComputeRegionNetworkPolicyTrafficClassificationRuleType
- FirebaseDatabaseInstanceDesiredState
- FirebaseDatabaseInstanceState
- FirebaseDatabaseInstanceType
- FirebaseExtensionsInstanceState
- FirebaseHostingCustomDomainCertPreference
- FirebaseHostingCustomDomainOwnershipState
- FirebaseHostingReleaseType
- GkeHubMembershipRbacRoleBindingPredefinedRole
- KmsFolderKajPolicyConfigAllowedAccessReasons
- KmsOrganizationKajPolicyConfigAllowedAccessReasons
- KmsProjectKajPolicyConfigAllowedAccessReasons
- NetworkSecurityAuthorizationPolicyAction
- NetworkSecuritySacAttachmentState
- NetworkSecuritySacRealmSecurityService
- NetworkSecuritySacRealmState
- NetworkServicesServiceLbPoliciesIsolationGranularity
- NetworkServicesServiceLbPoliciesIsolationMode
- NetworkServicesServiceLbPoliciesLoadBalancingAlgorithm
- OsConfigGuestPoliciesArchiveType
- OsConfigGuestPoliciesDesiredState
- OsConfigGuestPoliciesInterpreter
- OsConfigGuestPoliciesManager
- OsConfigGuestPoliciesType
- PrivilegedAccessManagerSettingsEntitlementAssigned
- PrivilegedAccessManagerSettingsGrantActivated
- PrivilegedAccessManagerSettingsGrantActivationFailed
- PrivilegedAccessManagerSettingsGrantDenied
- PrivilegedAccessManagerSettingsGrantEnded
- PrivilegedAccessManagerSettingsGrantExpired
- PrivilegedAccessManagerSettingsGrantExternallyModified
- PrivilegedAccessManagerSettingsGrantRevoked
- PrivilegedAccessManagerSettingsPendingApproval
- SaasRuntimeReleaseType
- SaasRuntimeRolloutKindUpdateUnitKindStrategy
- SecurityScannerScanConfigExportToSecurityCommandCenter
- SecurityScannerScanConfigTargetPlatforms
- SecurityScannerScanConfigUserAgent
- TpuV2VmMode
- VertexAiModelGardenEnableModelEnablementState
- Available extensions
Constructors
- TfArg.literal(T value)
-
A Dart value:
.literal('orders'),TfArg.literal('orders')(T inferred) orTfArg<String?>.literal(null)(explicit). A const constructor, so a helper built from literals can beconst.constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
encodeAs(
String attribute) → TfArg< Object?> -
Available on TfArg<
The argument value: each element's RefTo.encodeAs for a literal list, the value itself otherwise.List< , provided by the RefToList extensionRefTo< >R> > -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
toTfJson(
) → Object? - Value emitted into Terraform JSON.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
duration(
Duration duration) → TfArg< String> -
Convenience for Terraform duration-string fields
(
rotation_period,message_retention_duration,ack_deadline_secondswhen expressed in string-seconds form, etc.). -
expression<
T> (String template) → TfArg< T> -
Convenience:
TfArg.expression(r'${lower(var.name)}-x')(T inferred) orTfArg.expression<int>(r'${var.replicas * 2}')(explicit). -
variable<
T> (String name) → TfArg< T> -
var.<name>by name:.variable('db_password'). -
workspace<
T> () → TfArg< T> -
Convenience:
TfArg.workspace()— the name of the selected Terraform workspace,${terraform.workspace}.
Constants
- workspaceTemplate → const String
-
The template workspace emits:
${terraform.workspace}.