从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
EXPERTE
gefragt vor 6 Monaten43 Aufrufe
1 Antwort
0

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

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

profile picture
EXPERTE
beantwortet vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen

Relevanter Inhalt