我正在尝试使用 boto3 创建一个 AD 连接器,在密码部分中我需要从已创建的机密管理器中检索值。我无法弄清楚我可以传递什么值。
from aws_cdk import core as CDK
from aws_cdk import core
from aws_cdk import aws_ec2 as ec2
import botocore
import boto3
from aws_cdk import core
class AdConnectorBoto3Stack(cdk.Stack):
def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# The code that defines your stack goes here
client = boto3.client('ds')
sm_client = boto3.client('sm')
sm = client.get_secret_value(
SecretId='arn value',
#VersionId='string',
#VersionStage='string'
)
adconnector = client.connect_directory(
Name='corp.example.com',
ShortName='AWS',
Password=sm.secret_value_from_json("Key").to_string() ,
#Description='string',
Size='Small',
ConnectSettings={
'VpcId': 'vpc-0123456789',
'SubnetIds': [
'subnet-123456', 'subnet-77899'
],
'CustomerDnsIps': [
'192.168.0.169','192.168.0.237'
],
'CustomerUserName': 'admin'
},
Tags=[
{
'Key': 'app',
'Value': 'adconnector'
},
]
)