- Más nuevo
- Más votos
- Más comentarios
It looks like the primary change here was to split the resource types into separate ECS and EKS types.
So, instead of batch.JobDefinition
, there's batch.EcsJobDefinition
[1], along with batch.MultiNodeJobDefinition
[2], as well as an EKS equivalent. Either of these types will accept a container
parameter of the type batch.EcsEc2ContainerDefinition
[3]. In turn, the container definition will accept a secrets
parameter [4], which should work with the same ecs.Secret.from_secrets_manager
call you currently have.
Keep in mind that this is untested, but I believe your code should look something like this:
db_secret = secretsmanager.Secret(self, "secret")
batch.EcsJobDefinition(self, "batch-job-def-secrets",
container=batch.EcsEc2ContainerDefinition(
image=ecs.EcrImage.from_registry("docker/whalesay"),
secrets={
"PASSWORD": ecs.Secret.from_secrets_manager(db_secret, "password")
}
)
)
There may be some additional minor changes needed that I'm overlooking, but it does look like these new types mostly align with the previous ones for what parameters they expect. Overall though, it looks to me like a matter of simply using EcsJobDefinition
in place of JobDefinition
, and EcsEc2ContainerDefinition
in place of JobDefinitionContainer
.
[1] https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_batch_alpha/EcsJobDefinition.html [2] https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_batch_alpha/MultiNodeJobDefinition.html [3] https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_batch_alpha/EcsEc2ContainerDefinition.html [4] https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_secretsmanager/ISecret.html
Contenido relevante
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace un año
- ¿Cómo puedo hacer una llamada al SDK de AWS desde un proyecto de CDK mediante la interfaz AWSdkCall?OFICIAL DE AWSActualizada hace 10 meses
Thanks, Wayne.
Like you, I was expecting that the example would carry over to the new API in straightforward way. But it does not carry over: the type for
secrets
inEcsEc2ContainerDefinition
isSequence
, notDict
, so we cannot specify variable names likePASSWORD
to map a secrets to environment variables in a docker container. Hence my post.