# S3SourceActionProps

Struct · Stable

Construction properties of the `S3SourceAction S3 source Action`.

Extends: [CommonAwsActionProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.CommonAwsActionProps.html)
Used as props by: [S3SourceAction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline_actions.S3SourceAction.html)

- Source: [`aws-codepipeline-actions/lib/s3/source-action.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-codepipeline-actions/lib/s3/source-action.ts#L49)

## Example

TypeScript:

```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:

```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:

```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();
```

C#:

```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:

```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,
		},
	},
})
```

## Properties

- `actionName`: string (required) — The physical, human-readable name of the Action.

  Note that Action names must be unique within a single Stage.

- `bucket`: [IBucket](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html) (required) — The Amazon S3 bucket that stores the source code.

  If you import an encrypted bucket in your stack, please specify
  the encryption key at import time by using `Bucket.fromBucketAttributes()` method.

- `bucketKey`: string (required) — The key within the S3 bucket that stores the source code.

  ```ts
  'path/to/file.zip'
  ```

- `output`: [Artifact](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.Artifact.html) (required)

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The Role in which context's this Action will be executing in.

  **Default:** a new Role will be generated

  The Pipeline's Role will assume this Role
  (the required permissions for that will be granted automatically)
  right before executing this Action.
  This Action will be passed into your `IAction.bind`
  method in the `ActionBindOptions.role` property.

- `runOrder`: number = 1 — The runOrder property for this Action.

  RunOrder determines the relative order in which multiple Actions in the same Stage execute.

- `trigger`: [S3Trigger](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline_actions.S3Trigger.html) = S3Trigger.POLL — How should CodePipeline detect source changes for this Action.

  Note that if this is S3Trigger.EVENTS, you need to make sure to include the source Bucket in a CloudTrail Trail,
  as otherwise the CloudWatch Events will not be emitted.

- `variablesNamespace`: string — The name of the namespace to use for variables emitted by this action.

  **Default:** a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set
