feat(batch): new L2 Constructs#24775
Conversation
…s it to point them to the docs for the cluster page setup
…for noow. The EKS custom resource could handle this, in theory
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Prior to this change container secrets could be added to a I suppose now the secrets need to be set via |
|
Thanks for taking the new API for a spin! You should be able to do this now: import * as cdk from 'aws-cdk-lib';
import * as secrets from 'aws-cdk-lib/aws-secretsmanager';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import { Construct } from 'constructs';
import * as batch from '@aws-cdk/aws-batch-alpha';
export class FooStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new batch.EcsJobDefinition(this, 'job', {
container: new batch.EcsEc2ContainerDefinition(this, 'container', {
cpu: 256,
image: ecs.ContainerImage.fromRegistry('foo'),
memory: cdk.Size.mebibytes(2048),
secrets: [new secrets.Secret(this, 'mysecret')],
}),
});
}
}from aws_cdk import (
Stack,
aws_ecs as ecs,
aws_secretsmanager as secrets,
Size,
)
from constructs import Construct
from aws_cdk.aws_batch_alpha import EcsJobDefinition, EcsEc2ContainerDefinition
class FooPyStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
job_defn = EcsJobDefinition(self, "JobDefn",
container=EcsEc2ContainerDefinition(self, "containerDefn",
image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
memory=Size.mebibytes(2048),
cpu=256,
secrets=[secrets.Secret(self, 'Secret')]
)
) |
|
Thanks. What I am not seeing in your example is the mapping from a secret to an environment variable set in the Docker container. In the example I quoted a secret is made available in the Docker container per environment variable How is the secret to be accessed in the Docker container with the new API? |
|
I think this is the feature you're talking about: #20871 This is not supported in the new APIs, so I can add support for it; should just be changing the type from |
Pinning aws_batch_alpha to 2.71.0 to use the previous API. Current API has this failure:
Traceback (most recent call last):
File "app.py", line 1, in <module>
from aws_cdk import (aws_ec2 as ec2,
File "/tmp/.venv/lib/python3.7/site-packages/aws_cdk/aws_batch_alpha/__init__.py", line 6505, in <module>
typing_extensions.Protocol,
File "/tmp/.venv/lib/python3.7/site-packages/aws_cdk/aws_batch_alpha/__init__.py", line 6606, in IManagedEc2EcsComputeEnvironment
) -> typing.Optional[_aws_cdk_aws_ec2_ceddda9d.IPlacementGroup]:
AttributeError: module 'aws_cdk.aws_ec2' has no attribute 'IPlacementGroup'
Adds a new set of L2s for Batch. See https://github.com/aws/aws-cdk-rfcs/pull/484/files for details.
This contains breaking changes to the alpha module! To use the previous API, pin your version of
aws-batch-alphato2.71.0.BREAKING CHANGE:
ComputeEnvironmenthas been removed and replaced byManagedEc2EcsComputeEnvironment,ManagedEc2EksComputeEnvironment, andUnmanagedComputeEnvironment.JobDefinitionhas been removed and replaced byEcsJobDefinition,EksJobDefinition, andMultiNodeJobDefinitionBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license