# Amazon Neptune Construct Library
<!--BEGIN STABILITY BANNER-->---
![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)
> All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use.
![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.
---
<!--END STABILITY BANNER-->
Amazon Neptune is a fast, reliable, fully managed graph database service that makes it easy to build and run applications that work with highly connected datasets. The core of Neptune is a purpose-built, high-performance graph database engine. This engine is optimized for storing billions of relationships and querying the graph with milliseconds latency. Neptune supports the popular graph query languages Apache TinkerPop Gremlin and W3C’s SPARQL, enabling you to build queries that efficiently navigate highly connected datasets.
The `@aws-cdk/aws-neptune` package contains primitives for setting up Neptune database clusters and instances.
```python
import aws_cdk.aws_neptune as neptune
```
## Starting a Neptune Database
To set up a Neptune database, define a `DatabaseCluster`. You must always launch a database in a VPC.
```python
cluster = neptune.DatabaseCluster(self, "Database",
vpc=vpc,
instance_type=neptune.InstanceType.R5_LARGE
)
```
By default only writer instance is provisioned with this construct.
## Connecting
To control who can access the cluster, use the `.connections` attribute. Neptune databases have a default port, so
you don't need to specify the port:
```python
cluster.connections.allow_default_port_from_any_ipv4("Open to the world")
```
The endpoints to access your database cluster will be available as the `.clusterEndpoint` and `.clusterReadEndpoint`
attributes:
```python
write_address = cluster.cluster_endpoint.socket_address
```
## IAM Authentication
You can also authenticate to a database cluster using AWS Identity and Access Management (IAM) database authentication;
See [https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html](https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html) for more information and a list of supported
versions and limitations.
The following example shows enabling IAM authentication for a database cluster and granting connection access to an IAM role.
```python
cluster = neptune.DatabaseCluster(self, "Cluster",
vpc=vpc,
instance_type=neptune.InstanceType.R5_LARGE,
iam_authentication=True
)
role = iam.Role(self, "DBRole", assumed_by=iam.AccountPrincipal(self.account))
cluster.grant_connect(role)
```
## Customizing parameters
Neptune allows configuring database behavior by supplying custom parameter groups. For more details, refer to the
following link: [https://docs.aws.amazon.com/neptune/latest/userguide/parameters.html](https://docs.aws.amazon.com/neptune/latest/userguide/parameters.html)
```python
cluster_params = neptune.ClusterParameterGroup(self, "ClusterParams",
description="Cluster parameter group",
parameters={
"neptune_enable_audit_log": "1"
}
)
db_params = neptune.ParameterGroup(self, "DbParams",
description="Db parameter group",
parameters={
"neptune_query_timeout": "120000"
}
)
cluster = neptune.DatabaseCluster(self, "Database",
vpc=vpc,
instance_type=neptune.InstanceType.R5_LARGE,
cluster_parameter_group=cluster_params,
parameter_group=db_params
)
```
## Adding replicas
`DatabaseCluster` allows launching replicas along with the writer instance. This can be specified using the `instanceCount`
attribute.
```python
cluster = neptune.DatabaseCluster(self, "Database",
vpc=vpc,
instance_type=neptune.InstanceType.R5_LARGE,
instances=2
)
```
Additionally it is also possible to add replicas using `DatabaseInstance` for an existing cluster.
```python
replica1 = neptune.DatabaseInstance(self, "Instance",
cluster=cluster,
instance_type=neptune.InstanceType.R5_LARGE
)
```
## Automatic minor version upgrades
By setting `autoMinorVersionUpgrade` to true, Neptune will automatically update
the engine of the entire cluster to the latest minor version after a stabilization
window of 2 to 3 weeks.
```python
neptune.DatabaseCluster(self, "Cluster",
vpc=vpc,
instance_type=neptune.InstanceType.R5_LARGE,
auto_minor_version_upgrade=True
)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/aws/aws-cdk",
"name": "aws-cdk.aws-neptune",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Amazon Web Services",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/b5/86/0657d620534036392aa4fe2ee7c7faeeecd9f4ffbe05d38f6c40282f0b0d/aws-cdk.aws-neptune-1.199.0.tar.gz",
"platform": null,
"description": "# Amazon Neptune Construct Library\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)\n\n> All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use.\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n<!--END STABILITY BANNER-->\n\nAmazon Neptune is a fast, reliable, fully managed graph database service that makes it easy to build and run applications that work with highly connected datasets. The core of Neptune is a purpose-built, high-performance graph database engine. This engine is optimized for storing billions of relationships and querying the graph with milliseconds latency. Neptune supports the popular graph query languages Apache TinkerPop Gremlin and W3C\u2019s SPARQL, enabling you to build queries that efficiently navigate highly connected datasets.\n\nThe `@aws-cdk/aws-neptune` package contains primitives for setting up Neptune database clusters and instances.\n\n```python\nimport aws_cdk.aws_neptune as neptune\n```\n\n## Starting a Neptune Database\n\nTo set up a Neptune database, define a `DatabaseCluster`. You must always launch a database in a VPC.\n\n```python\ncluster = neptune.DatabaseCluster(self, \"Database\",\n vpc=vpc,\n instance_type=neptune.InstanceType.R5_LARGE\n)\n```\n\nBy default only writer instance is provisioned with this construct.\n\n## Connecting\n\nTo control who can access the cluster, use the `.connections` attribute. Neptune databases have a default port, so\nyou don't need to specify the port:\n\n```python\ncluster.connections.allow_default_port_from_any_ipv4(\"Open to the world\")\n```\n\nThe endpoints to access your database cluster will be available as the `.clusterEndpoint` and `.clusterReadEndpoint`\nattributes:\n\n```python\nwrite_address = cluster.cluster_endpoint.socket_address\n```\n\n## IAM Authentication\n\nYou can also authenticate to a database cluster using AWS Identity and Access Management (IAM) database authentication;\nSee [https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html](https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth.html) for more information and a list of supported\nversions and limitations.\n\nThe following example shows enabling IAM authentication for a database cluster and granting connection access to an IAM role.\n\n```python\ncluster = neptune.DatabaseCluster(self, \"Cluster\",\n vpc=vpc,\n instance_type=neptune.InstanceType.R5_LARGE,\n iam_authentication=True\n)\nrole = iam.Role(self, \"DBRole\", assumed_by=iam.AccountPrincipal(self.account))\ncluster.grant_connect(role)\n```\n\n## Customizing parameters\n\nNeptune allows configuring database behavior by supplying custom parameter groups. For more details, refer to the\nfollowing link: [https://docs.aws.amazon.com/neptune/latest/userguide/parameters.html](https://docs.aws.amazon.com/neptune/latest/userguide/parameters.html)\n\n```python\ncluster_params = neptune.ClusterParameterGroup(self, \"ClusterParams\",\n description=\"Cluster parameter group\",\n parameters={\n \"neptune_enable_audit_log\": \"1\"\n }\n)\n\ndb_params = neptune.ParameterGroup(self, \"DbParams\",\n description=\"Db parameter group\",\n parameters={\n \"neptune_query_timeout\": \"120000\"\n }\n)\n\ncluster = neptune.DatabaseCluster(self, \"Database\",\n vpc=vpc,\n instance_type=neptune.InstanceType.R5_LARGE,\n cluster_parameter_group=cluster_params,\n parameter_group=db_params\n)\n```\n\n## Adding replicas\n\n`DatabaseCluster` allows launching replicas along with the writer instance. This can be specified using the `instanceCount`\nattribute.\n\n```python\ncluster = neptune.DatabaseCluster(self, \"Database\",\n vpc=vpc,\n instance_type=neptune.InstanceType.R5_LARGE,\n instances=2\n)\n```\n\nAdditionally it is also possible to add replicas using `DatabaseInstance` for an existing cluster.\n\n```python\nreplica1 = neptune.DatabaseInstance(self, \"Instance\",\n cluster=cluster,\n instance_type=neptune.InstanceType.R5_LARGE\n)\n```\n\n## Automatic minor version upgrades\n\nBy setting `autoMinorVersionUpgrade` to true, Neptune will automatically update\nthe engine of the entire cluster to the latest minor version after a stabilization\nwindow of 2 to 3 weeks.\n\n```python\nneptune.DatabaseCluster(self, \"Cluster\",\n vpc=vpc,\n instance_type=neptune.InstanceType.R5_LARGE,\n auto_minor_version_upgrade=True\n)\n```\n\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "The CDK Construct Library for AWS::Neptune",
"version": "1.199.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8c0015e478f257f20c0458b8f52c24cd1e69f2c892d8a4e47739e46ba8379ae8",
"md5": "60588032b07dc7ebfc39a2a4f2a7e7d5",
"sha256": "fc519dcf4b3692059cec71a7d177b523f9d5857b324ee55662044c3c9a1ae5d9"
},
"downloads": -1,
"filename": "aws_cdk.aws_neptune-1.199.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "60588032b07dc7ebfc39a2a4f2a7e7d5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.7",
"size": 167641,
"upload_time": "2023-04-20T21:37:36",
"upload_time_iso_8601": "2023-04-20T21:37:36.761017Z",
"url": "https://files.pythonhosted.org/packages/8c/00/15e478f257f20c0458b8f52c24cd1e69f2c892d8a4e47739e46ba8379ae8/aws_cdk.aws_neptune-1.199.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b5860657d620534036392aa4fe2ee7c7faeeecd9f4ffbe05d38f6c40282f0b0d",
"md5": "8eedaa9162e84bf8101758e67aaec95f",
"sha256": "cd9dab91ac002cb3e96c5963b38cf54631527c245ce791e8cda572c466c00094"
},
"downloads": -1,
"filename": "aws-cdk.aws-neptune-1.199.0.tar.gz",
"has_sig": false,
"md5_digest": "8eedaa9162e84bf8101758e67aaec95f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.7",
"size": 168338,
"upload_time": "2023-04-20T21:45:19",
"upload_time_iso_8601": "2023-04-20T21:45:19.654546Z",
"url": "https://files.pythonhosted.org/packages/b5/86/0657d620534036392aa4fe2ee7c7faeeecd9f4ffbe05d38f6c40282f0b0d/aws-cdk.aws-neptune-1.199.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-20 21:45:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "aws",
"github_project": "aws-cdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aws-cdk.aws-neptune"
}