Script
- class aws_cdk.aws_gamelift_alpha.Script(scope, id, *, content, role=None, script_name=None, script_version=None)
Bases:
ScriptBase
(experimental) A GameLift script, that is installed and runs on instances in an Amazon GameLift fleet.
It consists of a zip file with all of the components of the realtime game server script.
- See:
- Stability:
experimental
- Resource:
AWS::GameLift::Script
- ExampleMetadata:
infused
Example:
# bucket: s3.Bucket gamelift.Script(self, "Script", content=gamelift.Content.from_bucket(bucket, "sample-asset-key") )
- Parameters:
scope (
Construct
) –id (
str
) –content (
Content
) – (experimental) The game content.role (
Optional
[IRole
]) – (experimental) The IAM role assumed by GameLift to access server script in S3. If providing a custom role, it needs to trust the GameLift service principal (gamelift.amazonaws.com) and be granted sufficient permissions to have Read access to a specific key content into a specific S3 bucket. Below an example of required permission: { “Version”: “2012-10-17”, “Statement”: [{ “Effect”: “Allow”, “Action”: [ “s3:GetObject”, “s3:GetObjectVersion” ], “Resource”: “arn:aws:s3:::bucket-name/object-name” }] } Default: - a role will be created with default permissions.script_name (
Optional
[str
]) – (experimental) Name of this realtime server script. Default: No namescript_version (
Optional
[str
]) – (experimental) Version of this realtime server script. Default: No version
- Stability:
experimental
Methods
- apply_removal_policy(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
).- Parameters:
policy (
RemovalPolicy
) –- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- env
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.
- grant_principal
(experimental) The principal this GameLift script is using.
- Stability:
experimental
- node
The tree node.
- role
(experimental) The IAM role GameLift assumes to acccess server script content.
- Stability:
experimental
- script_arn
(experimental) The ARN of the realtime server script.
- Stability:
experimental
- script_id
(experimental) The Identifier of the realtime server script.
- Stability:
experimental
- stack
The stack in which this resource is defined.
Static Methods
- classmethod from_asset(scope, id, path, *, deploy_time=None, readers=None, source_kms_key=None, asset_hash=None, asset_hash_type=None, bundling=None, exclude=None, follow_symlinks=None, ignore_mode=None)
(experimental) Create a new realtime server script from asset content.
- Parameters:
scope (
Construct
) –id (
str
) –path (
str
) –deploy_time (
Optional
[bool
]) – Whether or not the asset needs to exist beyond deployment time; i.e. are copied over to a different location and not needed afterwards. Setting this property to true has an impact on the lifecycle of the asset, because we will assume that it is safe to delete after the CloudFormation deployment succeeds. For example, Lambda Function assets are copied over to Lambda during deployment. Therefore, it is not necessary to store the asset in S3, so we consider those deployTime assets. Default: falsereaders (
Optional
[Sequence
[IGrantable
]]) – A list of principals that should be able to read this asset from S3. You can useasset.grantRead(principal)
to grant read permissions later. Default: - No principals that can read file asset.source_kms_key (
Optional
[IKey
]) – The ARN of the KMS key used to encrypt the handler code. Default: - the default server-side encryption with Amazon S3 managed keys(SSE-S3) key will be used.asset_hash (
Optional
[str
]) – Specify a custom hash for this asset. IfassetHashType
is set it must be set toAssetHashType.CUSTOM
. For consistency, this custom hash will be SHA256 hashed and encoded as hex. The resulting hash will be the asset hash. NOTE: the hash is used in order to identify a specific revision of the asset, and used for optimizing and caching deployment activities related to this asset such as packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will need to make sure it is updated every time the asset changes, or otherwise it is possible that some deployments will not be invalidated. Default: - based onassetHashType
asset_hash_type (
Optional
[AssetHashType
]) – Specifies the type of hash to calculate for this asset. IfassetHash
is configured, this option must beundefined
orAssetHashType.CUSTOM
. Default: - the default isAssetHashType.SOURCE
, but ifassetHash
is explicitly specified this value defaults toAssetHashType.CUSTOM
.bundling (
Union
[BundlingOptions
,Dict
[str
,Any
],None
]) – Bundle the asset by executing a command in a Docker container or a custom bundling provider. The asset path will be mounted at/asset-input
. The Docker container is responsible for putting content at/asset-output
. The content at/asset-output
will be zipped and used as the final asset. Default: - uploaded as-is to S3 if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to S3 otherwiseexclude (
Optional
[Sequence
[str
]]) – File paths matching the patterns will be excluded. SeeignoreMode
to set the matching behavior. Has no effect on Assets bundled using thebundling
property. Default: - nothing is excludedfollow_symlinks (
Optional
[SymlinkFollowMode
]) – A strategy for how to handle symlinks. Default: SymlinkFollowMode.NEVERignore_mode (
Optional
[IgnoreMode
]) – The ignore behavior to use forexclude
patterns. Default: IgnoreMode.GLOB
- Stability:
experimental
- Return type:
- classmethod from_bucket(scope, id, bucket, key, object_version=None)
(experimental) Create a new realtime server script from s3 content.
- classmethod from_script_arn(scope, id, script_arn)
(experimental) Import a script into CDK using its ARN.
- classmethod from_script_attributes(scope, id, *, script_arn, role=None)
(experimental) Import an existing realtime server script from its attributes.
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool