> **Experimental**
>
> `@aws-cdk/aws-apprunner-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# Source

Represents the App Runner service source.

Superclass of: [AssetSource](/cdk/api/v2/docs/@aws-cdk_aws-apprunner-alpha.AssetSource.html), [EcrPublicSource](/cdk/api/v2/docs/@aws-cdk_aws-apprunner-alpha.EcrPublicSource.html), [EcrSource](/cdk/api/v2/docs/@aws-cdk_aws-apprunner-alpha.EcrSource.html), [GithubSource](/cdk/api/v2/docs/@aws-cdk_aws-apprunner-alpha.GithubSource.html)

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/service.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts#L415)

## Example

TypeScript:

```ts
import * as iam from 'aws-cdk-lib/aws-iam';

const service = new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromEcrPublic({
    imageConfiguration: { port: 8000 },
    imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
  }),
});

service.addToRolePolicy(new iam.PolicyStatement({
  effect: iam.Effect.ALLOW,
  actions: ['s3:GetObject'],
  resources: ['*'],
}))
```

Python:

```python
import aws_cdk.aws_iam as iam

service = apprunner.Service(self, "Service",
    source=apprunner.Source.from_ecr_public(
        image_configuration=apprunner.ImageConfiguration(port=8000),
        image_identifier="public.ecr.aws/aws-containers/hello-app-runner:latest"
    )
)

service.add_to_role_policy(iam.PolicyStatement(
    effect=iam.Effect.ALLOW,
    actions=["s3:GetObject"],
    resources=["*"]
))
```

Java:

```java
import software.amazon.awscdk.services.iam.*;

Service service = Service.Builder.create(this, "Service")
        .source(Source.fromEcrPublic(EcrPublicProps.builder()
                .imageConfiguration(ImageConfiguration.builder().port(8000).build())
                .imageIdentifier("public.ecr.aws/aws-containers/hello-app-runner:latest")
                .build()))
        .build();

service.addToRolePolicy(PolicyStatement.Builder.create()
        .effect(Effect.ALLOW)
        .actions(List.of("s3:GetObject"))
        .resources(List.of("*"))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.AppRunner.Alpha
using Amazon.CDK.AWS.IAM;

var service = new Service(this, "Service", new ServiceProps {
    Source = Source.FromEcrPublic(new EcrPublicProps {
        ImageConfiguration = new ImageConfiguration { Port = 8000 },
        ImageIdentifier = "public.ecr.aws/aws-containers/hello-app-runner:latest"
    })
});

service.AddToRolePolicy(new PolicyStatement(new PolicyStatementProps {
    Effect = Effect.ALLOW,
    Actions = new [] { "s3:GetObject" },
    Resources = new [] { "*" }
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkapprunneralpha/v2
import "github.com/aws/aws-cdk-go/awscdk"

service := apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromEcrPublic(&EcrPublicProps{
		ImageConfiguration: &ImageConfiguration{
			Port: jsii.Number(8000),
		},
		ImageIdentifier: jsii.String("public.ecr.aws/aws-containers/hello-app-runner:latest"),
	}),
})

service.AddToRolePolicy(iam.NewPolicyStatement(&PolicyStatementProps{
	Effect: iam.Effect_ALLOW,
	Actions: []*string{
		jsii.String("s3:GetObject"),
	},
	Resources: []*string{
		jsii.String("*"),
	},
}))
```

## Initializer

TypeScript:

```ts
new Source()
```

Python:

```python
Source()
```

Java:

```java
new Source()
```

C# / .NET:

```csharp
new Source()
```

Golang:

```go
NewSource()
```

## Methods

- `bind(scope: Construct): SourceConfig` — Called when the Job is initialized to allow this object to bind.

- `fromAsset(props: AssetProps): AssetSource` (static) — Source from local assets.

- `fromEcr(props: EcrProps): EcrSource` (static) — Source from the ECR repository.

- `fromEcrPublic(props: EcrPublicProps): EcrPublicSource` (static) — Source from the ECR Public repository.

- `fromGitHub(props: GithubRepositoryProps): GithubSource` (static) — Source from the GitHub repository.
