Class: AWSCDK::Pipelines::CodeBuildStepProps

Inherits:
ShellStepProps
  • Object
show all
Defined in:
pipelines/code_build_step_props.rb

Overview

Construction props for a CodeBuildStep.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commands:, additional_inputs: nil, env: nil, env_from_cfn_outputs: nil, input: nil, install_commands: nil, primary_output_directory: nil, action_role: nil, build_environment: nil, cache: nil, file_system_locations: nil, logging: nil, partial_build_spec: nil, project_name: nil, role: nil, role_policy_statements: nil, security_groups: nil, subnet_selection: nil, timeout: nil, vpc: nil) ⇒ CodeBuildStepProps

Returns a new instance of CodeBuildStepProps.

Parameters:

  • commands (Array<String>)

    Commands to run.

  • additional_inputs (Hash{String => AWSCDK::Pipelines::IFileSetProducer}, nil) (defaults to: nil)

    Additional FileSets to put in other directories.

  • env (Hash{String => String}, nil) (defaults to: nil)

    Environment variables to set.

  • env_from_cfn_outputs (Hash{String => AWSCDK::CfnOutput}, nil) (defaults to: nil)

    Set environment variables based on Stack Outputs.

  • input (AWSCDK::Pipelines::IFileSetProducer, nil) (defaults to: nil)

    FileSet to run these scripts on.

  • install_commands (Array<String>, nil) (defaults to: nil)

    Installation commands to run before the regular commands.

  • primary_output_directory (String, nil) (defaults to: nil)

    The directory that will contain the primary output fileset.

  • action_role (AWSCDK::IAM::IRole, nil) (defaults to: nil)

    Custom execution role to be used for the Code Build Action.

  • build_environment (AWSCDK::CodeBuild::BuildEnvironment, nil) (defaults to: nil)

    Changes to environment.

  • cache (AWSCDK::CodeBuild::Cache, nil) (defaults to: nil)

    Caching strategy to use.

  • file_system_locations (Array<AWSCDK::CodeBuild::IFileSystemLocation>, nil) (defaults to: nil)

    ProjectFileSystemLocation objects for CodeBuild build projects.

  • logging (AWSCDK::CodeBuild::LoggingOptions, nil) (defaults to: nil)

    Information about logs for CodeBuild projects.

  • partial_build_spec (AWSCDK::CodeBuild::BuildSpec, nil) (defaults to: nil)

    Additional configuration that can only be configured via BuildSpec.

  • project_name (String, nil) (defaults to: nil)

    Name for the generated CodeBuild project.

  • role (AWSCDK::IAM::IRole, nil) (defaults to: nil)

    Custom execution role to be used for the CodeBuild project.

  • role_policy_statements (Array<AWSCDK::IAM::PolicyStatement>, nil) (defaults to: nil)

    Policy statements to add to role used during the synth.

  • security_groups (Array<AWSCDK::EC2::ISecurityGroup>, nil) (defaults to: nil)

    Which security group to associate with the script's project network interfaces.

  • subnet_selection (AWSCDK::EC2::SubnetSelection, nil) (defaults to: nil)

    Which subnets to use.

  • timeout (AWSCDK::Duration, nil) (defaults to: nil)

    The number of minutes after which AWS CodeBuild stops the build if it's not complete.

  • vpc (AWSCDK::EC2::IVPC, nil) (defaults to: nil)

    The VPC where to execute the SimpleSynth.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'pipelines/code_build_step_props.rb', line 27

def initialize(commands:, additional_inputs: nil, env: nil, env_from_cfn_outputs: nil, input: nil, install_commands: nil, primary_output_directory: nil, action_role: nil, build_environment: nil, cache: nil, file_system_locations: nil, logging: nil, partial_build_spec: nil, project_name: nil, role: nil, role_policy_statements: nil, security_groups: nil, subnet_selection: nil, timeout: nil, vpc: nil)
  @commands = commands
  Jsii::Type.check_type(@commands, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "commands")
  @additional_inputs = additional_inputs
  Jsii::Type.check_type(@additional_inputs, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLnBpcGVsaW5lcy5JRmlsZVNldFByb2R1Y2VyIn0sImtpbmQiOiJtYXAifX0=")), "additionalInputs") unless @additional_inputs.nil?
  @env = env
  Jsii::Type.check_type(@env, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "env") unless @env.nil?
  @env_from_cfn_outputs = env_from_cfn_outputs
  Jsii::Type.check_type(@env_from_cfn_outputs, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLkNmbk91dHB1dCJ9LCJraW5kIjoibWFwIn19")), "envFromCfnOutputs") unless @env_from_cfn_outputs.nil?
  @input = input
  Jsii::Type.check_type(@input, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5waXBlbGluZXMuSUZpbGVTZXRQcm9kdWNlciJ9")), "input") unless @input.nil?
  @install_commands = install_commands
  Jsii::Type.check_type(@install_commands, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "installCommands") unless @install_commands.nil?
  @primary_output_directory = primary_output_directory
  Jsii::Type.check_type(@primary_output_directory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "primaryOutputDirectory") unless @primary_output_directory.nil?
  @action_role = action_role
  Jsii::Type.check_type(@action_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "actionRole") unless @action_role.nil?
  @build_environment = build_environment.is_a?(Hash) ? ::AWSCDK::CodeBuild::BuildEnvironment.new(**build_environment.transform_keys(&:to_sym)) : build_environment
  Jsii::Type.check_type(@build_environment, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZWJ1aWxkLkJ1aWxkRW52aXJvbm1lbnQifQ==")), "buildEnvironment") unless @build_environment.nil?
  @cache = cache
  Jsii::Type.check_type(@cache, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZWJ1aWxkLkNhY2hlIn0=")), "cache") unless @cache.nil?
  @file_system_locations = file_system_locations
  Jsii::Type.check_type(@file_system_locations, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19jb2RlYnVpbGQuSUZpbGVTeXN0ZW1Mb2NhdGlvbiJ9LCJraW5kIjoiYXJyYXkifX0=")), "fileSystemLocations") unless @file_system_locations.nil?
  @logging = logging.is_a?(Hash) ? ::AWSCDK::CodeBuild::LoggingOptions.new(**logging.transform_keys(&:to_sym)) : logging
  Jsii::Type.check_type(@logging, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZWJ1aWxkLkxvZ2dpbmdPcHRpb25zIn0=")), "logging") unless @logging.nil?
  @partial_build_spec = partial_build_spec
  Jsii::Type.check_type(@partial_build_spec, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZWJ1aWxkLkJ1aWxkU3BlYyJ9")), "partialBuildSpec") unless @partial_build_spec.nil?
  @project_name = project_name
  Jsii::Type.check_type(@project_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "projectName") unless @project_name.nil?
  @role = role
  Jsii::Type.check_type(@role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "role") unless @role.nil?
  @role_policy_statements = role_policy_statements
  Jsii::Type.check_type(@role_policy_statements, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19pYW0uUG9saWN5U3RhdGVtZW50In0sImtpbmQiOiJhcnJheSJ9fQ==")), "rolePolicyStatements") unless @role_policy_statements.nil?
  @security_groups = security_groups
  Jsii::Type.check_type(@security_groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lYzIuSVNlY3VyaXR5R3JvdXAifSwia2luZCI6ImFycmF5In19")), "securityGroups") unless @security_groups.nil?
  @subnet_selection = subnet_selection.is_a?(Hash) ? ::AWSCDK::EC2::SubnetSelection.new(**subnet_selection.transform_keys(&:to_sym)) : subnet_selection
  Jsii::Type.check_type(@subnet_selection, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN1Ym5ldFNlbGVjdGlvbiJ9")), "subnetSelection") unless @subnet_selection.nil?
  @timeout = timeout
  Jsii::Type.check_type(@timeout, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "timeout") unless @timeout.nil?
  @vpc = vpc
  Jsii::Type.check_type(@vpc, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklWcGMifQ==")), "vpc") unless @vpc.nil?
end

Instance Attribute Details

#action_roleAWSCDK::IAM::IRole? (readonly)

Note:

Default: - A role is automatically created

Custom execution role to be used for the Code Build Action.

Returns:



142
143
144
# File 'pipelines/code_build_step_props.rb', line 142

def action_role
  @action_role
end

#additional_inputsHash{String => AWSCDK::Pipelines::IFileSetProducer}? (readonly)

Note:

Default: - No additional inputs

Additional FileSets to put in other directories.

Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated.

The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:

# Example automatically generated from non-compiling source. May contain errors.
script = Pipelines::ShellStep.new("MainScript", {
    commands: ["npm ci", "npm run build", "npx cdk synth"],
    input: Pipelines::CodePipelineSource.git_hub("org/source1", "main"),
    additional_inputs: {
        "../siblingdir" => Pipelines::CodePipelineSource.git_hub("org/source2", "main"),
    },
})

Returns:



97
98
99
# File 'pipelines/code_build_step_props.rb', line 97

def additional_inputs
  @additional_inputs
end

#build_environmentAWSCDK::CodeBuild::BuildEnvironment? (readonly)

Note:

Default: - Use the pipeline's default build environment

Changes to environment.

This environment will be combined with the pipeline's default environment.



150
151
152
# File 'pipelines/code_build_step_props.rb', line 150

def build_environment
  @build_environment
end

#cacheAWSCDK::CodeBuild::Cache? (readonly)

Note:

Default: - No cache

Caching strategy to use.

Returns:



155
156
157
# File 'pipelines/code_build_step_props.rb', line 155

def cache
  @cache
end

#commandsArray<String> (readonly)

Commands to run.

Returns:

  • (Array<String>)


73
74
75
# File 'pipelines/code_build_step_props.rb', line 73

def commands
  @commands
end

#envHash{String => String}? (readonly)

Note:

Default: - No environment variables

Environment variables to set.

Returns:

  • (Hash{String => String}, nil)


102
103
104
# File 'pipelines/code_build_step_props.rb', line 102

def env
  @env
end

#env_from_cfn_outputsHash{String => AWSCDK::CfnOutput}? (readonly)

Note:

Default: - No environment variables created from stack outputs

Set environment variables based on Stack Outputs.

ShellSteps following stack or stage deployments may access the CfnOutputs of those stacks to get access to --for example--automatically generated resource names or endpoint URLs.

Returns:



112
113
114
# File 'pipelines/code_build_step_props.rb', line 112

def env_from_cfn_outputs
  @env_from_cfn_outputs
end

#file_system_locationsArray<AWSCDK::CodeBuild::IFileSystemLocation>? (readonly)

Note:

Default: - no file system locations

ProjectFileSystemLocation objects for CodeBuild build projects.

A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System.



163
164
165
# File 'pipelines/code_build_step_props.rb', line 163

def file_system_locations
  @file_system_locations
end

#inputAWSCDK::Pipelines::IFileSetProducer? (readonly)

Note:

Default: - No input specified

FileSet to run these scripts on.

The files in the FileSet will be placed in the working directory when the script is executed. Use additional_inputs to download file sets to other directories as well.



121
122
123
# File 'pipelines/code_build_step_props.rb', line 121

def input
  @input
end

#install_commandsArray<String>? (readonly)

Note:

Default: - No installation commands

Installation commands to run before the regular commands.

For deployment engines that support it, install commands will be classified differently in the job history from the regular commands.

Returns:

  • (Array<String>, nil)


129
130
131
# File 'pipelines/code_build_step_props.rb', line 129

def install_commands
  @install_commands
end

#loggingAWSCDK::CodeBuild::LoggingOptions? (readonly)

Note:

Default: - no log configuration is set

Information about logs for CodeBuild projects.

A CodeBuild project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.



170
171
172
# File 'pipelines/code_build_step_props.rb', line 170

def logging
  @logging
end

#partial_build_specAWSCDK::CodeBuild::BuildSpec? (readonly)

Note:

Default: - BuildSpec completely derived from other properties

Additional configuration that can only be configured via BuildSpec.

You should not use this to specify output artifacts; those should be supplied via the other properties of this class, otherwise CDK Pipelines won't be able to inspect the artifacts.

Set the commands to an empty array if you want to fully specify the BuildSpec using this field.

The BuildSpec must be available inline--it cannot reference a file on disk.



185
186
187
# File 'pipelines/code_build_step_props.rb', line 185

def partial_build_spec
  @partial_build_spec
end

#primary_output_directoryString? (readonly)

Note:

Default: - No primary output

The directory that will contain the primary output fileset.

After running the script, the contents of the given directory will be treated as the primary output of this Step.

Returns:

  • (String, nil)


137
138
139
# File 'pipelines/code_build_step_props.rb', line 137

def primary_output_directory
  @primary_output_directory
end

#project_nameString? (readonly)

Note:

Default: - Automatically generated

Name for the generated CodeBuild project.

Returns:

  • (String, nil)


190
191
192
# File 'pipelines/code_build_step_props.rb', line 190

def project_name
  @project_name
end

#roleAWSCDK::IAM::IRole? (readonly)

Note:

Default: - A role is automatically created

Custom execution role to be used for the CodeBuild project.

Returns:



195
196
197
# File 'pipelines/code_build_step_props.rb', line 195

def role
  @role
end

#role_policy_statementsArray<AWSCDK::IAM::PolicyStatement>? (readonly)

Note:

Default: - No policy statements added to CodeBuild Project Role

Policy statements to add to role used during the synth.

Can be used to add access to a CodeArtifact repository etc.

Returns:



202
203
204
# File 'pipelines/code_build_step_props.rb', line 202

def role_policy_statements
  @role_policy_statements
end

#security_groupsArray<AWSCDK::EC2::ISecurityGroup>? (readonly)

Note:

Default: - Security group will be automatically created.

Which security group to associate with the script's project network interfaces.

If no security group is identified, one will be created automatically.

Only used if 'vpc' is supplied.

Returns:



211
212
213
# File 'pipelines/code_build_step_props.rb', line 211

def security_groups
  @security_groups
end

#subnet_selectionAWSCDK::EC2::SubnetSelection? (readonly)

Note:

Default: - All private subnets.

Which subnets to use.

Only used if 'vpc' is supplied.



218
219
220
# File 'pipelines/code_build_step_props.rb', line 218

def subnet_selection
  @subnet_selection
end

#timeoutAWSCDK::Duration? (readonly)

Note:

Default: Duration.hours(1)

The number of minutes after which AWS CodeBuild stops the build if it's not complete.

For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.

Returns:



226
227
228
# File 'pipelines/code_build_step_props.rb', line 226

def timeout
  @timeout
end

#vpcAWSCDK::EC2::IVPC? (readonly)

Note:

Default: - No VPC

The VPC where to execute the SimpleSynth.

Returns:



231
232
233
# File 'pipelines/code_build_step_props.rb', line 231

def vpc
  @vpc
end

Class Method Details

.jsii_propertiesObject



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'pipelines/code_build_step_props.rb', line 233

def self.jsii_properties
  {
    :commands => "commands",
    :additional_inputs => "additionalInputs",
    :env => "env",
    :env_from_cfn_outputs => "envFromCfnOutputs",
    :input => "input",
    :install_commands => "installCommands",
    :primary_output_directory => "primaryOutputDirectory",
    :action_role => "actionRole",
    :build_environment => "buildEnvironment",
    :cache => "cache",
    :file_system_locations => "fileSystemLocations",
    :logging => "logging",
    :partial_build_spec => "partialBuildSpec",
    :project_name => "projectName",
    :role => "role",
    :role_policy_statements => "rolePolicyStatements",
    :security_groups => "securityGroups",
    :subnet_selection => "subnetSelection",
    :timeout => "timeout",
    :vpc => "vpc",
  }
end

Instance Method Details

#to_jsiiObject



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'pipelines/code_build_step_props.rb', line 258

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "commands" => @commands,
    "additionalInputs" => @additional_inputs,
    "env" => @env,
    "envFromCfnOutputs" => @env_from_cfn_outputs,
    "input" => @input,
    "installCommands" => @install_commands,
    "primaryOutputDirectory" => @primary_output_directory,
    "actionRole" => @action_role,
    "buildEnvironment" => @build_environment,
    "cache" => @cache,
    "fileSystemLocations" => @file_system_locations,
    "logging" => @logging,
    "partialBuildSpec" => @partial_build_spec,
    "projectName" => @project_name,
    "role" => @role,
    "rolePolicyStatements" => @role_policy_statements,
    "securityGroups" => @security_groups,
    "subnetSelection" => @subnet_selection,
    "timeout" => @timeout,
    "vpc" => @vpc,
  })
  result.compact
end