从Lambda检索AWS参数时发生访问被拒绝异常。

0

【以下的问题经过翻译处理】 我正在尝试从使用C#开发的Lambda访问系统参数。

根据https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html#ps-integration-lambda-extensions-sample-commands中的说明,我添加了所需的lambda层。

Lambda执行角色在IAM定义中包含以下内容(使用“??????”替换实际帐户ID)

{
    “Version”:“2012-10-17”,
    “Statement”:[
        {
            “Sid”:“VisualEditor0”,
            “Effect”:“Allow”,
            “Action”:[
                “ssm:*”
            ],
            “Resource”:“arn:aws:ssm:*:??????????:parameter / *”
        }
    ]
}

根据上述AWS页面引用,我向http://localhost:2773/systemsmanager/parameters/get/?name=/ClinMod/SyncfusionKey&version=1发出了HTTP GET请求。

这会导致以下响应失败

{
    "Version": "1.1",
    "Content": {
        "Headers": [
            {
                "Key": "Content-Type",
                "Value": [
                    "text/plain"
                ]
            },
            {
                "Key": "Content-Length",
                "Value": [
                    "31"
                ]
            }
        ]
    },
    "StatusCode": 401,
    "ReasonPhrase": "Unauthorized",
    "Headers": [
        {
            "Key": "X-Amzn-Errortype",
            "Value": [
                "AccessDeniedException"
            ]
        },
        {
            "Key": "Date",
            "Value": [
                "Thu, 01 Dec 2022 12:16:59 GMT"
            ]
        }
    ],
    "TrailingHeaders": [],
    "RequestMessage": {
        "Version": "1.1",
        "VersionPolicy": 0,
        "Content": null,
        "Method": {
            "Method": "GET"
        },
        "RequestUri": "http://localhost:2773/systemsmanager/parameters/get/?name=/ClinMod/SyncfusionKey&version=1",
        "Headers": [],
        "Properties": {},
        "Options": {}
    },
    "IsSuccessStatusCode": false
}

有什么线索我哪里出错了吗?

profile picture
专家
已提问 5 个月前36 查看次数
1 回答
0

【以下的回答经过翻译处理】 嗨,Richard,

您是否将带有“AWS_SESSION_TOKEN”的“X-Aws-Parameters-Secrets-Token”标头添加到您的请求中?

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则