class Service (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.AppRunner.Alpha.Service |
![]() | github.com/aws/aws-cdk-go/awscdkapprunneralpha/v2#Service |
![]() | software.amazon.awscdk.services.apprunner.alpha.Service |
![]() | aws_cdk.aws_apprunner_alpha.Service |
![]() | @aws-cdk/aws-apprunner-alpha ยป Service |
Implements
IConstruct
, IDependable
, IResource
, IService
, IGrantable
The App Runner Service.
Example
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: ['*'],
}))
Initializer
new Service(scope: Construct, id: string, props: ServiceProps)
Parameters
- scope
Construct
- id
string
- props
Service
Props
Construct Props
Name | Type | Description |
---|---|---|
source | Source | The source of the repository for the service. |
access | IRole | The IAM role that grants the App Runner service access to a source repository. |
auto | boolean | Specifies whether to enable continuous integration from the source repository. |
auto | IAuto | Specifies an App Runner Auto Scaling Configuration. |
cpu? | Cpu | The number of CPU units reserved for each instance of your App Runner service. |
health | Health | Settings for the health check that AWS App Runner performs to monitor the health of a service. |
instance | IRole | The IAM role that provides permissions to your App Runner service. |
ip | Ip | The IP address type for your incoming public network configuration. |
is | boolean | Specifies whether your App Runner service is publicly accessible. |
kms | IKey | The customer managed key that AWS App Runner uses to encrypt copies of the source repository and service logs. |
memory? | Memory | The amount of memory reserved for each instance of your App Runner service. |
observability | IObservability | Settings for an App Runner observability configuration. |
service | string | Name of the service. |
vpc | IVpc | Settings for an App Runner VPC connector to associate with the service. |
source
Type:
Source
The source of the repository for the service.
accessRole?
Type:
IRole
(optional, default: generate a new access role.)
The IAM role that grants the App Runner service access to a source repository.
It's required for ECR image repositories (but not for ECR Public repositories).
The role must be assumable by the 'build.apprunner.amazonaws.com' service principal.
autoDeploymentsEnabled?
Type:
boolean
(optional, default: no value will be passed.)
Specifies whether to enable continuous integration from the source repository.
If true, continuous integration from the source repository is enabled for the App Runner service. Each repository change (including any source code commit or new image version) starts a deployment. By default, App Runner sets to false for a source image that uses an ECR Public repository or an ECR repository that's in an AWS account other than the one that the service is in. App Runner sets to true in all other cases (which currently include a source code repository or a source image using a same-account ECR repository).
autoScalingConfiguration?
Type:
IAuto
(optional, default: the latest revision of a default auto scaling configuration is used.)
Specifies an App Runner Auto Scaling Configuration.
A default configuration is either the AWS recommended configuration, or the configuration you set as the default.
See also: https://docs.aws.amazon.com/apprunner/latest/dg/manage-autoscaling.html
cpu?
Type:
Cpu
(optional, default: Cpu.ONE_VCPU)
The number of CPU units reserved for each instance of your App Runner service.
healthCheck?
Type:
Health
(optional, default: no health check configuration)
Settings for the health check that AWS App Runner performs to monitor the health of a service.
You can specify it by static methods HealthCheck.http
or HealthCheck.tcp
.
instanceRole?
Type:
IRole
(optional, default: generate a new instance role.)
The IAM role that provides permissions to your App Runner service.
These are permissions that your code needs when it calls any AWS APIs.
The role must be assumable by the 'tasks.apprunner.amazonaws.com' service principal.
ipAddressType?
Type:
Ip
(optional, default: IpAddressType.IPV4)
The IP address type for your incoming public network configuration.
isPubliclyAccessible?
Type:
boolean
(optional, default: true)
Specifies whether your App Runner service is publicly accessible.
If you use VpcIngressConnection
, you must set this property to false
.
kmsKey?
Type:
IKey
(optional, default: Use an AWS managed key)
The customer managed key that AWS App Runner uses to encrypt copies of the source repository and service logs.
memory?
Type:
Memory
(optional, default: Memory.TWO_GB)
The amount of memory reserved for each instance of your App Runner service.
observabilityConfiguration?
Type:
IObservability
(optional, default: no observability configuration resource is associated with the service.)
Settings for an App Runner observability configuration.
serviceName?
Type:
string
(optional, default: auto-generated if undefined.)
Name of the service.
vpcConnector?
Type:
IVpc
(optional, default: no VPC connector, uses the DEFAULT egress type instead)
Settings for an App Runner VPC connector to associate with the service.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
environment | { [string]: string } | Environment variables for this service. |
grant | IPrincipal | The principal to grant permissions to. |
node | Node | The tree node. |
service | string | The ARN of the Service. |
service | string | The ID of the Service. |
service | string | The name of the service. |
service | string | The status of the Service. |
service | string | The URL of the Service. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
environment
โ ๏ธ Deprecated: use environmentVariables.
Type:
{ [string]: string }
Environment variables for this service.
grantPrincipal
Type:
IPrincipal
The principal to grant permissions to.
node
Type:
Node
The tree node.
serviceArn
Type:
string
The ARN of the Service.
serviceId
Type:
string
The ID of the Service.
serviceName
Type:
string
The name of the service.
serviceStatus
Type:
string
The status of the Service.
serviceUrl
Type:
string
The URL of the Service.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
add | This method adds an environment variable to the App Runner service. |
add | This method adds a secret as environment variable to the App Runner service. |
add | Adds a statement to the instance role. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import from service attributes. |
static from | Import from service name. |
addEnvironmentVariable(name, value)
public addEnvironmentVariable(name: string, value: string): void
Parameters
- name
string
- value
string
This method adds an environment variable to the App Runner service.
addSecret(name, secret)
public addSecret(name: string, secret: Secret): void
Parameters
- name
string
- secret
Secret
This method adds a secret as environment variable to the App Runner service.
addToRolePolicy(statement)
public addToRolePolicy(statement: PolicyStatement): void
Parameters
- statement
Policy
Statement
Adds a statement to the instance role.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromServiceAttributes(scope, id, attrs)
public static fromServiceAttributes(scope: Construct, id: string, attrs: ServiceAttributes): IService
Parameters
- scope
Construct
- id
string
- attrs
Service
Attributes
Returns
Import from service attributes.
static fromServiceName(scope, id, serviceName)
public static fromServiceName(scope: Construct, id: string, serviceName: string): IService
Parameters
- scope
Construct
- id
string
- serviceName
string
Returns
Import from service name.