Section | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Variables are substituted in all Task configuration text fields (e.g. Stack Name, Template URL, Instance ID, Volume ID etc.).Please note the following feature
Note | ||
---|---|---|
| ||
Tasks may emit sensitive data like credentials which are not supposed to surface in build logs - this can be achieved as follows:
|
...
|
Variable Definition
Variables are defined by all most Tasks for reuse in subsequent Tasks as follows, see Bamboo Variable Substitution/Definition for details, and each task's documentation for example log outputs.
- A task's generated variables might get amended with respective AWS API additions over time - a live build log will always provide the most current variable shape accordingly.
Example
This example illustrates the variable generation pattern:
- variables have a dedicated prefix like
bamboo.custom.aws.*
, with*
being a task specific prefix, e.g.bamboo.custom.aws.cloudformation.stack
- variables referring to a collection of resources provide their ids in a semicolon separated list (i.e. the same format available on input), e.g.
${bamboo.custom.aws.ec2.imageinstance.resources}
with valuesamii-985b21f1a316b842;ami-9a5b21f3i-b4210842 (line 2)
you can refer to these variables from subsequent tasks via something like
bamboo.${
cfn.stack.sampleStackOutputKey}custom.aws.ec2.
- these variables are also available as environment variables in the Script Task for example, albeit named slightly different, e.g.
$bamboo_custom_aws_cfn_stack_StringWithRegex
(Unix) or%bamboo_custom_aws_cfn_stack_StringWithRegex%
(Windows)
Info | ||
---|---|---|
| ||
|
Available Task Variables
The following variables are available in the various tasks:
AWS CloudFormation Stack
...
relevant resource values for each affected stack, e.g. custom.
aws.cloudformation.stack.resources.
=CREATE_COMPLETESampleStack-42
.StackStatus
- properties converted to variables: StackName, StackStatus, CreationTime, LastUpdatedTime
- collection converted to variables: tags, parameters, resources, outputs
...
- the value of each provided stack parameter , e.g.
bamboo.custom.aws.
cloudformation
.stack.
.resources.
SampleStack-42
parameters
.NumberWithRange
=2
...
- the value of each generated stack output, e.g.
bamboo.custom.aws.
cloudformation
.stack.
.StringWithRegex=Hello
.outputsresources.
SampleStack-42
...
relevant resource values for each affected stack resource, e.g.
custom.
aws.cloudformation.stack.resources.
=CREATE_COMPLETESampleStack-42
.resources.i-3280997f
.ResourceStatus- properties converted to variables: ResourceStatus, LogicalResourceId, PhysicalResourceId, Timestamp
...
Info | ||
---|---|---|
| ||
CloudFormation Variables had been named inconsistently in previous versions of this add-on - the following names are deprecated, but remain available for compatibility reasons for the time being:
|
AWS Elastic Beanstalk Environment
- the collection of affected environments, e.g.
bamboo.custom.aws.elasticbeanstalk.environment.resources=e-3rcffs78rn
relevant resource values for each affected environment, e.g.
custom.
aws.cloudformation.stack.resources.
=CREATE_COMPLETESampleStack-42
.StackStatus- properties converted to variables: EnvironmentId, ApplicationName, CNAME, DateCreated, DateUpdated, Description, EndpointURL, EnvironmentName, Health, SolutionStackName, Status, TemplateName, VersionLabel
Amazon EC2 Instance
- the collection of affected instances, e.g.
bamboo.custom.aws.ec2.instance.resources=i-fa7b4596;i-080eec64
relevant resource values for each affected instance, e.g.
custom.aws.ec2.image.resources.
i-fa7b4596
.State=running- properties converted to variables: InstanceId, State, PrivateDnsName, PrivateIpAddress, PublicDnsName, PublicIpAddress, LaunchTime
- collection converted to variables: tags
Amazon EC2 Image
- the collection of affected images, e.g.
bamboo.custom.aws.ec2.image.resources=ami-985b21f1;ami-9a5b21f3
- relevant resource values for each affected image, e.g.
custom.aws.ec2.image.resources.
ami-985b21f1
.State=available- properties converted to variables: ImageId, State
- collection converted to variables: tags
Amazon EBS Snapshots
- the collection of affected snapshots, e.g.
bamboo.custom.aws.ec2.snapshots.resources=snap-f4dc35a1
- relevant resource values for each affected snapshot, e.g.
custom.aws.ec2.
snapshot
.resources.snap-f4dc35a1
.State=completed
- properties converted to variables: SnapshotId, State, VolumeId, VolumeSize, StartTime collection converted to variables: tags
variables are also available as environment variables in the Script Task for example, albeit named slightly different, e.g.
$bamboo_custom_aws_cfn_stack_StringWithRegex
(Unix) or%bamboo_custom_aws_cfn_stack_StringWithRegex%
(Windows)variables are locally scoped and thus only reusable in subsequent tasks and not in other jobs/stages due to the implied concurrency, see the following discussion and workaround
instance.resources.i-a316b842.PrivateDnsName}
(line 6)
- however, given script access to such a named resource is difficult, there is a shortcut to ease reusing the first (and often only) affected resource via something like ${custom.aws.ec2.instance.first.i-a316b842.PrivateDnsName}
: (line 19)
Code Block | ||||
---|---|---|---|---|
| ||||
Creating common variables for 2 resources affected by task:
... custom.aws.ec2.instance.resources: i-a316b842;i-b4210842
Creating resource variables for instance 'i-a316b842':
... custom.aws.ec2.instance.resources.i-a316b842.InstanceId: i-a316b842
... custom.aws.ec2.instance.resources.i-a316b842.State: running
... custom.aws.ec2.instance.resources.i-a316b842.PrivateDnsName: ip-10-0-0-241.ec2.internal
... custom.aws.ec2.instance.resources.i-a316b842.PrivateIpAddress: 10.0.0.241
... custom.aws.ec2.instance.resources.i-a316b842.PublicDnsName:
... custom.aws.ec2.instance.resources.i-a316b842.PublicIpAddress: null
... custom.aws.ec2.instance.resources.i-a316b842.LaunchTime: 20150716T080402Z
... custom.aws.ec2.instance.resources.i-a316b842.tags: Name
... custom.aws.ec2.instance.resources.i-a316b842.tags.Name: taws-it-2.0.0
Creating resource variables for instance 'i-b4210842':
... <skipped>
Creating common variables for first resource affected by task:
Creating resource variables for instance 'i-a316b842':
... custom.aws.ec2.instance.first.InstanceId: i-a316b842
... custom.aws.ec2.instance.first.State: running
... custom.aws.ec2.instance.first.PrivateDnsName: ip-10-0-0-241.ec2.internal
... custom.aws.ec2.instance.first.PrivateIpAddress: 10.0.0.241
... custom.aws.ec2.instance.first.PublicDnsName:
... custom.aws.ec2.instance.first.PublicIpAddress: null
... custom.aws.ec2.instance.first.LaunchTime: 20150716T080402Z
... custom.aws.ec2.instance.first.tags: Name
... custom.aws.ec2.instance.first.tags.Name: taws-it-2.0.0 |