Ich habe einen AWS CDK v2-Stack (Python) geändert, um eine API Gateway v2-Stufe mit aktivierter Protokollierung zu generieren. Klingt einfach, es gibt unzählige Beispiele im Internet und unzählige Agenten-Codierungstools, die bereit sind, es zu generieren. Dennoch funktioniert bei mir keines davon.
Mein vorhandenes CDK-Snippet sieht so aus:
import aws_cdk as cdk
from aws_cdk import (
aws_ecs as ecs,
aws_ec2 as ec2,
aws_ecr_assets as ecr_assets,
aws_logs as logs,
aws_certificatemanager as acm,
aws_elasticloadbalancingv2 as elbv2,
aws_apigatewayv2 as apigwv2,
aws_apigateway as apigwv1,
aws_apigatewayv2_integrations as apigwv2_integrations,
aws_iam as iam
)
from constructs import Construct
import os
Was ich mit so etwas erweitere (unzählige andere Permutationen ausprobiert):
Es gibt Schnittstellen wie IAccessLogSettings, aber diese Objekte (AccessLogSettings, AccessLogFormat), von denen die AWS-Dokumentation und unzählige Google-Suchanfragen behaupten, dass sie vorhanden sein sollten, sind nicht vorhanden.
Nehmen Sie dieses Beispiel von Gemini (ich habe ähnliches von Claude, GPT erhalten), das dem gleichen Format folgt. Dies erzeugt auch die gleichen Fehler.
from aws_cdk import aws_apigatewayv2 as apigwv2
# Assuming 'http_api' is your existing apigwv2.HttpApi instance
# and 'log_group' is the LogGroup created in the previous step.
stage = apigwv2.HttpStage(
self,
"MyHttpStage",
http_api=http_api,
stage_name="dev", # Or your desired stage name
access_log_settings=apigwv2.AccessLogSettings(
destination=apigwv2.LogGroupLogDestination(log_group),
format=apigwv2.AccessLogFormat.json_with_standard_fields(
caller=True,
http_method=True,
ip=True,
protocol=True,
request_time=date_time=True,
resource_path=True,
response_length=True,
status=True,
user=True,
),
),
)
Hier ist eine vollständige CDK-Synth-Ausgabe, falls sie hilfreich ist.
% cdk synth
Traceback (most recent call last):
File "/.../cdk.py", line 9, in
ServiceStack(app, "ServiceStack", env=ServiceEnv.get_env())
File "/.../.pyenv/versions/3.12.12/lib/python3.12/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../cdk/stack.py", line 151, in __init__
access_log_settings=apigwv2.AccessLogSettings(
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'aws_cdk.aws_apigatewayv2' has no attribute 'AccessLogSettings'. Did you mean: 'IAccessLogSettings'?
Plattform: Mac M4 Pro
Python-Version: 3.12.12
CDK-Version: 2.220.0
Dieses Problem besteht weiterhin auf einem Linux-basierten CI-Bereitstellungssystem und ist daher nicht spezifisch für meine lokale Box. Ich bin damit an eine Wand gestoßen. Ich bin neu bei Python CDK, aber weder bei Python noch bei CDK einzeln.
Was verursacht diese Diskrepanz zwischen der veröffentlichten Dokumentation für CDK und dem, was meine Umgebung anscheinend importiert hat?
Ich habe einen AWS CDK v2-Stack (Python) geändert, um eine API Gateway v2-Stufe mit aktivierter Protokollierung zu generieren. Klingt einfach, es gibt unzählige Beispiele im Internet und unzählige Agenten-Codierungstools, die bereit sind, es zu generieren. Dennoch funktioniert bei mir keines davon. Mein vorhandenes CDK-Snippet sieht so aus: [code] # HTTP API Gateway with logging enabled http_api = apigwv2.HttpApi( self, "ServiceHttpApi", api_name="ServiceApi", description="API Gateway for Service" ) [/code] mit Importen: [code]import aws_cdk as cdk from aws_cdk import ( aws_ecs as ecs, aws_ec2 as ec2, aws_ecr_assets as ecr_assets, aws_logs as logs, aws_certificatemanager as acm, aws_elasticloadbalancingv2 as elbv2, aws_apigatewayv2 as apigwv2, aws_apigateway as apigwv1, aws_apigatewayv2_integrations as apigwv2_integrations, aws_iam as iam ) from constructs import Construct import os [/code] Was ich mit so etwas erweitere (unzählige andere Permutationen ausprobiert): [code] # HTTP API Gateway with logging enabled http_api = apigwv2.HttpApi( self, "ServiceHttpApi", api_name="ServiceApi", description="API Gateway for Service" )
stage = apigwv2.HttpStage(self, "Stage", http_api=http_api, access_log_settings=apigwv2.AccessLogSettings( destination=apigwv2.LogGroupLogDestination(api_log_group), format=apigwv2.AccessLogFormat.json_with_standard_fields() ) ) [/code] Zu den Fehlern, die ich erhalte, gehören: [code]'aws_cdk.aws_apigatewayv2' has no attribute 'AccessLogSettings' 'aws_cdk.aws_apigatewayv2' has no attribute 'AccessLogFormat' [/code] Zusätzlich zur Überprüfung, dass meine Versionen akzeptabel waren: [code]aws-cdk-lib>=2.220.0,=10.0.0,>> import aws_cdk >>> dir(aws_cdk.aws_apigatewayv2) ['AccessLogDestinationConfig', 'AddApiKeyOptions', 'AddRoutesOptions', 'ApiGatewayManagedOverridesReference', 'ApiKey', 'ApiKeyOptions', 'ApiKeyProps', 'ApiMapping', 'ApiMappingAttributes', 'ApiMappingProps', 'ApiMappingReference', 'ApiReference', 'AuthorizerPayloadVersion', 'AuthorizerReference', 'BatchHttpRouteOptions', 'CfnApi', 'CfnApiGatewayManagedOverrides', 'CfnApiGatewayManagedOverridesProps', 'CfnApiMapping', 'CfnApiMappingProps', 'CfnApiProps', 'CfnAuthorizer', 'CfnAuthorizerProps', 'CfnDeployment', 'CfnDeploymentProps', 'CfnDomainName', 'CfnDomainNameProps', 'CfnIntegration', 'CfnIntegrationProps', 'CfnIntegrationResponse', 'CfnIntegrationResponseProps', 'CfnModel', 'CfnModelProps', 'CfnRoute', 'CfnRouteProps', 'CfnRouteResponse', 'CfnRouteResponseProps', 'CfnRoutingRule', 'CfnRoutingRuleProps', 'CfnStage', 'CfnStageProps', 'CfnVpcLink', 'CfnVpcLinkProps', 'ContentHandling', 'CorsHttpMethod', 'CorsPreflightOptions', 'DeploymentReference', 'DomainMappingOptions', 'DomainName', 'DomainNameAttributes', 'DomainNameProps', 'DomainNameReference', 'EndpointOptions', 'EndpointType', 'GrantInvokeOptions', 'HttpApi', 'HttpApiAttributes', 'HttpApiProps', 'HttpAuthorizer', 'HttpAuthorizerAttributes', 'HttpAuthorizerProps', 'HttpAuthorizerType', 'HttpConnectionType', 'HttpIntegration', 'HttpIntegrationProps', 'HttpIntegrationSubtype', 'HttpIntegrationType', 'HttpMethod', 'HttpNoneAuthorizer', 'HttpRoute', 'HttpRouteAuthorizerBindOptions', 'HttpRouteAuthorizerConfig', 'HttpRouteIntegration', 'HttpRouteIntegrationBindOptions', 'HttpRouteIntegrationConfig', 'HttpRouteKey', 'HttpRouteProps', 'HttpStage', 'HttpStageAttributes', 'HttpStageOptions', 'HttpStageProps', 'IAccessLogDestination', 'IAccessLogSettings', 'IApi', 'IApiGatewayManagedOverridesRef', 'IApiKey', 'IApiMapping', 'IApiMappingRef', 'IApiRef', 'IAuthorizer', 'IAuthorizerRef', 'IDeploymentRef', 'IDomainName', 'IDomainNameRef', 'IHttpApi', 'IHttpAuthorizer', 'IHttpIntegration', 'IHttpRoute', 'IHttpRouteAuthorizer', 'IHttpStage', 'IIntegration', 'IIntegrationRef', 'IIntegrationResponseRef', 'IMappingValue', 'IModelRef', 'IRoute', 'IRouteRef', 'IRouteResponseRef', 'IRoutingRuleRef', 'IStage', 'IStageRef', 'IUsagePlan', 'IVpcLink', 'IVpcLinkRef', 'IWebSocketApi', 'IWebSocketAuthorizer', 'IWebSocketIntegration', 'IWebSocketRoute', 'IWebSocketRouteAuthorizer', 'IWebSocketStage', 'IntegrationCredentials', 'IntegrationReference', 'IntegrationResponseReference', 'IpAddressType', 'LogGroupLogDestination', 'MTLSConfig', 'MappingValue', 'ModelReference', 'ParameterMapping', 'PassthroughBehavior', 'PayloadFormatVersion', 'Period', 'QuotaSettings', 'RateLimitedApiKey', 'RateLimitedApiKeyProps', 'RouteReference', 'RouteResponseReference', 'RoutingRuleReference', 'SecurityPolicy', 'StageAttributes', 'StageOptions', 'StageReference', 'ThrottleSettings', 'UsagePlan', 'UsagePlanPerApiStage', 'UsagePlanProps', 'VpcLink', 'VpcLinkAttributes', 'VpcLinkProps', 'VpcLinkReference', 'WebSocketApi', 'WebSocketApiAttributes', 'WebSocketApiKeySelectionExpression', 'WebSocketApiProps', 'WebSocketAuthorizer', 'WebSocketAuthorizerAttributes', 'WebSocketAuthorizerProps', 'WebSocketAuthorizerType', 'WebSocketIntegration', 'WebSocketIntegrationProps', 'WebSocketIntegrationType', 'WebSocketNoneAuthorizer', 'WebSocketRoute', 'WebSocketRouteAuthorizerBindOptions', 'WebSocketRouteAuthorizerConfig', 'WebSocketRouteIntegration', 'WebSocketRouteIntegrationBindOptions', 'WebSocketRouteIntegrationConfig', 'WebSocketRouteOptions', 'WebSocketRouteProps', 'WebSocketStage', 'WebSocketStageAttributes', 'WebSocketStageProps', '__all__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_private'] [/code] Es gibt Schnittstellen wie IAccessLogSettings, aber diese Objekte (AccessLogSettings, AccessLogFormat), von denen die AWS-Dokumentation und unzählige Google-Suchanfragen behaupten, dass sie vorhanden sein sollten, sind nicht vorhanden. Nehmen Sie dieses Beispiel von Gemini (ich habe ähnliches von Claude, GPT erhalten), das dem gleichen Format folgt. Dies erzeugt auch die gleichen Fehler. [code] from aws_cdk import aws_apigatewayv2 as apigwv2
# Assuming 'http_api' is your existing apigwv2.HttpApi instance # and 'log_group' is the LogGroup created in the previous step.
stage = apigwv2.HttpStage( self, "MyHttpStage", http_api=http_api, stage_name="dev", # Or your desired stage name access_log_settings=apigwv2.AccessLogSettings( destination=apigwv2.LogGroupLogDestination(log_group), format=apigwv2.AccessLogFormat.json_with_standard_fields( caller=True, http_method=True, ip=True, protocol=True, request_time=date_time=True, resource_path=True, response_length=True, status=True, user=True, ), ), ) [/code] Hier ist eine vollständige CDK-Synth-Ausgabe, falls sie hilfreich ist. [code]% cdk synth Traceback (most recent call last): File "/.../cdk.py", line 9, in ServiceStack(app, "ServiceStack", env=ServiceEnv.get_env()) File "/.../.pyenv/versions/3.12.12/lib/python3.12/site-packages/jsii/_runtime.py", line 118, in __call__ inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../cdk/stack.py", line 151, in __init__ access_log_settings=apigwv2.AccessLogSettings( ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'aws_cdk.aws_apigatewayv2' has no attribute 'AccessLogSettings'. Did you mean: 'IAccessLogSettings'? [/code] Plattform: Mac M4 Pro Python-Version: 3.12.12 CDK-Version: 2.220.0 Dieses [url=viewtopic.php?t=26065]Problem[/url] besteht weiterhin auf einem Linux-basierten CI-Bereitstellungssystem und ist daher nicht spezifisch für meine lokale Box. Ich bin damit an eine Wand gestoßen. Ich bin neu bei Python CDK, aber weder bei Python noch bei CDK einzeln. Was verursacht diese Diskrepanz zwischen der veröffentlichten Dokumentation für CDK und dem, was meine Umgebung anscheinend importiert hat?
Ich habe einen AWS CDK v2-Stack (Python) geändert, um eine API Gateway v2-Stufe mit aktivierter Protokollierung zu generieren. Klingt einfach, es gibt unzählige Beispiele im Internet und unzählige...
Ich versuche, mein API -Gateway in AWS durch die CDK einzurichten. Ich habe es eingerichtet, aber egal was ich versuche, ich kann CORS nicht umgehen, um die Lambda -Funktion auszuführen, die die...
Ich verwende den Juli -Logger von Tomcat und die Properties -Datei, um einen Tomcat -Einbettungsserver zu starten, in dem ein einzelnes WebApp namens MyApp auf Localhost vorhanden ist....
Applicaiton wird auf UWSGI+Django REST Framework ausgeführt. httpd Server leiten Sie die Anforderung auf 127.0.0.1:9000 proxypass/myapi uwsgi: //127.0.0.1: 9000
Code> Konfiguration in INI Datei....
Ich habe zwei Webdienste erstellt: Der erste ist ein ASP .NET -Kern für einen Rastfull -HTTP -Dienst; Der zweite ist ein ASP .NET -Kern mit MVC. Der erste hat APIs, die einige Daten in der Datenbank...