AWS code-library documentation change
Summary
Added Python SDK example for CreateGraph with VPC networking requirements note and error handling
Security assessment
The change adds documentation about mandatory VPC network isolation for Neptune access (security best practice) but does not address a specific vulnerability. The VPC guidance explains security controls but isn't tied to a disclosed security issue.
Diff
diff --git a/code-library/latest/ug/neptune_example_neptune_CreateGraph_section.md b/code-library/latest/ug/neptune_example_neptune_CreateGraph_section.md index b94214999..6f816642b 100644 --- a//code-library/latest/ug/neptune_example_neptune_CreateGraph_section.md +++ b//code-library/latest/ug/neptune_example_neptune_CreateGraph_section.md @@ -9 +9 @@ There are more AWS SDK examples available in the [AWS Doc SDK Examples](https:// -The following code example shows how to use `CreateGraph`. +The following code examples show how to use `CreateGraph`. @@ -63,0 +64,67 @@ There's more on GitHub. Find the complete example and learn how to set up and ru +Python + + +**SDK for Python (Boto3)** + + +###### Note + +There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/neptune#code-examples). + + + """ + Running this example. + + ---------------------------------------------------------------------------------- + VPC Networking Requirement: + ---------------------------------------------------------------------------------- + Amazon Neptune must be accessed from **within the same VPC** as the Neptune cluster. + It does not expose a public endpoint, so this code must be executed from: + + - An **AWS Lambda function** configured to run inside the same VPC + - An **EC2 instance** or **ECS task** running in the same VPC + - A connected environment such as a **VPN**, **AWS Direct Connect**, or a **peered VPC** + + """ + + GRAPH_NAME = "sample-analytics-graph" + + def main(): + config = Config(retries={"total_max_attempts": 1, "mode": "standard"}, read_timeout=None) + client = boto3.client("neptune-graph", config=config) + execute_create_graph(client, GRAPH_NAME) + + def execute_create_graph(client, graph_name): + try: + print("Creating Neptune graph...") + response = client.create_graph( + graphName=graph_name, + provisionedMemory = 16 + ) + + created_graph_name = response.get("name") + graph_arn = response.get("arn") + graph_endpoint = response.get("endpoint") + + print("Graph created successfully!") + print(f"Graph Name: {created_graph_name}") + print(f"Graph ARN: {graph_arn}") + print(f"Graph Endpoint: {graph_endpoint}") + + except ClientError as e: + print(f"Failed to create graph: {e.response['Error']['Message']}") + except BotoCoreError as e: + print(f"Failed to create graph: {str(e)}") + except Exception as e: + print(f"Unexpected error: {str(e)}") + + if __name__ == "__main__": + main() + + + + * For API details, see [CreateGraph](https://docs.aws.amazon.com/goto/boto3/neptune-2014-10-31/CreateGraph) in _AWS SDK for Python (Boto3) API Reference_. + + + +