Skip to content
v2.273.0

S3SourceAction Class ​

Source that is provided by a specific Amazon S3 object.

Will trigger the pipeline as soon as the S3 object changes, but only if there is a CloudTrail Trail in the account that captures the S3 event.

Example ​

ts
const key = 'some/key.zip';
declare const sourceBucket: s3.Bucket;
const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.S3SourceAction({
  actionName: 'S3Source',
  bucketKey: key,
  bucket: sourceBucket,
  output: sourceOutput,
  variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you
});

// later:
declare const project: codebuild.PipelineProject;
new codepipeline_actions.CodeBuildAction({
  actionName: 'CodeBuild',
  project,
  input: sourceOutput,
  environmentVariables: {
    VERSION_ID: {
      value: sourceAction.variables.versionId,
    },
  },
});
python
# source_bucket: s3.Bucket

# later:
# project: codebuild.PipelineProject
key = "some/key.zip"
source_output = codepipeline.Artifact()
source_action = codepipeline_actions.S3SourceAction(
    action_name="S3Source",
    bucket_key=key,
    bucket=source_bucket,
    output=source_output,
    variables_namespace="MyNamespace"
)
codepipeline_actions.CodeBuildAction(
    action_name="CodeBuild",
    project=project,
    input=source_output,
    environment_variables={
        "VERSION_ID": codebuild.BuildEnvironmentVariable(
            value=source_action.variables.version_id
        )
    }
)
java
Bucket sourceBucket;

// later:
PipelineProject project;
String key = "some/key.zip";
Artifact sourceOutput = new Artifact();
S3SourceAction sourceAction = S3SourceAction.Builder.create()
        .actionName("S3Source")
        .bucketKey(key)
        .bucket(sourceBucket)
        .output(sourceOutput)
        .variablesNamespace("MyNamespace")
        .build();
CodeBuildAction.Builder.create()
        .actionName("CodeBuild")
        .project(project)
        .input(sourceOutput)
        .environmentVariables(Map.of(
                "VERSION_ID", BuildEnvironmentVariable.builder()
                        .value(sourceAction.getVariables().getVersionId())
                        .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Bucket sourceBucket;

// later:
PipelineProject project;
var key = "some/key.zip";
var sourceOutput = new Artifact();
var sourceAction = new S3SourceAction(new S3SourceActionProps {
    ActionName = "S3Source",
    BucketKey = key,
    Bucket = sourceBucket,
    Output = sourceOutput,
    VariablesNamespace = "MyNamespace"
});
new CodeBuildAction(new CodeBuildActionProps {
    ActionName = "CodeBuild",
    Project = project,
    Input = sourceOutput,
    EnvironmentVariables = new Dictionary<string, BuildEnvironmentVariable> {
        { "VERSION_ID", new BuildEnvironmentVariable {
            Value = sourceAction.Variables.VersionId
        } }
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var sourceBucket Bucket

// later:
var project PipelineProject
key := "some/key.zip"
sourceOutput := codepipeline.NewArtifact()
sourceAction := codepipeline_actions.NewS3SourceAction(&S3SourceActionProps{
	ActionName: jsii.String("S3Source"),
	BucketKey: key,
	Bucket: sourceBucket,
	Output: sourceOutput,
	VariablesNamespace: jsii.String("MyNamespace"),
})
codepipeline_actions.NewCodeBuildAction(&CodeBuildActionProps{
	ActionName: jsii.String("CodeBuild"),
	Project: Project,
	Input: sourceOutput,
	EnvironmentVariables: map[string]BuildEnvironmentVariable{
		"VERSION_ID": &BuildEnvironmentVariable{
			"value": sourceAction.variables.versionId,
		},
	},
})

Initializer ​

ts
new S3SourceAction(props: S3SourceActionProps)
python
S3SourceAction(props: S3SourceActionProps)
java
new S3SourceAction(S3SourceActionProps props)
csharp
new S3SourceAction(S3SourceActionProps props)
go
NewS3SourceAction(Props S3SourceActionProps)

Properties ​

actionPropertiesActionPropertiesaction_propertiesActionPropertiesactionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesrequired#
The simple properties of the Action, like its Owner, name, etc.

Note that this accessor will be called before the bind callback.

The variables emitted by this action.

Methods ​

bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfigdef bind(self, scope: Construct, stage: IStage, options: ActionBindOptions) -> ActionConfigpublic ActionConfig bind(Construct scope, IStage stage, ActionBindOptions options)public ActionConfig Bind(Construct scope, IStage stage, ActionBindOptions options)func Bind(Scope Construct, Stage IStage, Options ActionBindOptions) ActionConfig#
The callback invoked when this Action is added to a Pipeline.
onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Ruledef on_state_change(self, name: str, target: typing.Optional[IRuleTarget] = None, options: typing.Optional[RuleProps] = None) -> Rulepublic Rule onStateChange(String name, IRuleTarget target, RuleProps options)public Rule OnStateChange(string name, IRuleTarget? target = null, RuleProps? options = null)func OnStateChange(Name *string, Target IRuleTarget, Options RuleProps) Rule#
Creates an Event that will be triggered whenever the state of this Action changes.