From 681ac1d2ba691e765e575864f1fb72d0d3702ef0 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 6 Jun 2018 08:28:17 +0100 Subject: [PATCH] Update aws 2.0.0.RC2 --- .../2.0.0.RC2/multi/multi__basic_setup.html | 14 +- .../multi/multi__cloud_environment.html | 16 ++- .../multi__using_amazon_web_services.html | 3 +- .../multi/multi_spring-cloud-aws.html | 2 +- .../2.0.0.RC2/single/spring-cloud-aws.html | 35 ++++- .../2.0.0.RC2/spring-cloud-aws.xml | 128 +++++++++++++++++- 6 files changed, 181 insertions(+), 17 deletions(-) diff --git a/spring-cloud-aws/2.0.0.RC2/multi/multi__basic_setup.html b/spring-cloud-aws/2.0.0.RC2/multi/multi__basic_setup.html index 9feaf1eb..639b6c69 100644 --- a/spring-cloud-aws/2.0.0.RC2/multi/multi__basic_setup.html +++ b/spring-cloud-aws/2.0.0.RC2/multi/multi__basic_setup.html @@ -37,9 +37,9 @@ use of the modules. A typical XML configuration to use Spring Cloud AWS is outli <aws-context:context-region region="..."/> </beans>

2.2.1 SDK credentials configuration

In order to make calls to the Amazon Web Service the credentials must be configured for the the Amazon SDK. Spring Cloud AWS provides support to configure an application context specific credentials that are used for each service call for requests done -by Spring Cloud AWS components. Therefore there must be exactly one configuration of the credentials for an entire application -context.

[Tip]Tip

The com.amazonaws.auth.DefaultAWSCredentialsProviderChain is used by all the clients if there is no dedicated credentials - provider defined. This will essentially use the following authentication information

  • use the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  • use the system properties aws.accessKeyId and aws.secretKey
  • use the user specific profile credentials file
  • use the instance profile credentials (see below)

Based on the overall credentials policy there are different options to configure the credentials. The possible ones are described in +by Spring Cloud AWS components, with the exception of the Parameter Store Configuration. +Therefore there must be exactly one configuration of the credentials for an entire application context.

[Tip]Tip

The com.amazonaws.auth.DefaultAWSCredentialsProviderChain is used by all the clients if there is no dedicated credentials + provider defined. This will essentially use the following authentication information

  • use the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  • use the system properties aws.accessKeyId and aws.secretKey
  • use the user specific profile credentials file
  • use ECS credentials if the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable is set
  • use the instance profile credentials (see below)

Based on the overall credentials policy there are different options to configure the credentials. The possible ones are described in the following sub-chapters.

Simple credentials configuration

Credentials for the Amazon SDK consist of an access key (which might be shared) and a secret key (which must not be shared). Both security attributes can be configured using the XML namespaces for each Amazon SDK service created by the Spring Cloud AWS module. The overall configuration looks like this

<beans ...>
@@ -62,7 +62,13 @@ EC2 (e.g. on a test server) and locally for testing. The next snippet shows a co
        <aws-context:simple-credentials access-key="${accessKey:}" secret-key="${secretKey:}"/>
    </aws-context:context-credentials>
 </beans>
[Tip]Tip

The access-key and secret-key are defined using a placeholder expressions along with a default value to avoid bootstrap -errors if the properties are not configured at all.

2.2.2 Region configuration

Amazon Web services are available in different regions. Based +errors if the properties are not configured at all.

Parameter Store Configuration credentials and region configuration

The Parameter Store Configuration support uses a bootstrap context to configure a default AWSSimpleSystemsManagement +client, which uses a com.amazonaws.auth.DefaultAWSCredentialsProviderChain and com.amazonaws.regions.DefaultAwsRegionProviderChain. +If you want to override this, then you need to +define your own Spring Cloud bootstrap configuration class +with a bean of type AWSSimpleSystemsManagement that’s configured to use your chosen credentials and/or region provider. +Because this context is created when your Spring Cloud Bootstrap context is created, you can’t simply override the bean +in a regular @Configuration class.

2.2.2 Region configuration

Amazon Web services are available in different regions. Based on the custom requirements, the user can host the application on different Amazon regions. The spring-cloud-aws-context module provides a way to define the region for the entire application context.

Explicit region configuration

The region can be explicitly configured using an XML element. This is particularly useful if the region can not be automatically derived because the application is not hosted on a EC2 instance (e.g. local testing) or the region must be manually overridden.

<beans ...>
diff --git a/spring-cloud-aws/2.0.0.RC2/multi/multi__cloud_environment.html b/spring-cloud-aws/2.0.0.RC2/multi/multi__cloud_environment.html
index 4c31963a..61a3e4a3 100644
--- a/spring-cloud-aws/2.0.0.RC2/multi/multi__cloud_environment.html
+++ b/spring-cloud-aws/2.0.0.RC2/multi/multi__cloud_environment.html
@@ -135,4 +135,18 @@ the specified region and security credentials. Application developers can inject
 	public ApplicationService(AmazonEC2 amazonEc2) {
 		this.amazonEc2 = amazonEc2;
 	}
-}
\ No newline at end of file +}

3.2 Integrating your Spring Cloud application with the AWS Parameter Store

Spring Cloud provides support for centralized configuration, which can be read and made available as a regular Spring +PropertySource when the application is started. The Parameter Store Configuration allows you to use this mechanism +with the AWS Parameter Store.

Simply add a dependency on the spring-cloud-starter-aws-parameter-store-config starter module to activate the support. +The support is similar to the support provided for the Spring Cloud Config Server or Consul’s key-value store: +configuration parameters can be defined to be shared across all services or for a specific service and can be +profile-specific. Encrypted values will be decrypted when retrieved.

All configuration parameters are retrieved from a common path prefix, which defaults to /config. From there shared +parameters are retrieved from a path that defaults to application and service-specific parameters use a path that +defaults to the configured spring.application.name. You can use both dots and forward slashes to specify the names +of configuration keys. Names of activated profiles will be appended to the path using a separator that defaults to an +underscore.

That means that for a service called my-service the module by default would find and use these parameters:

parameter keySpring propertydescription

/config/application/cloud.aws.stack.name

cloud.aws.stack.name

Shared by all services that have the Configuration support enabled. Can be overridden with a service- or profile-specific property.

/config/application_production/cloud.aws.stack.name

cloud.aws.stack.name

Shared by all services that have the Configuration support enabled and have a production Spring profile activated. + Can be overridden with a service-specific property.

/config/my-service/cloud/aws/stack/auto

cloud.aws.stack.auto

Specific to the my-service service. Note that slashes in the key path are replaced with dots.

/config/my-service_production/cloud/aws/stack/auto

cloud.aws.stack.auto

Specific to the my-service service when a production Spring profile is activated.

Note that this module does not support full configuration files to be used as parameter values like e.g. Spring Cloud Consul does: +AWS parameter values are limited to 4096 characters, so we support individual Spring properties to be configured only.

You can configure the following settings in a Spring Cloud bootstrap.properties or bootstrap.yml file +(note that relaxed property binding is applied, so you don’t have to use this exact syntax):

propertydefaultexplanation

aws.paramstore.prefix

/config

Prefix indicating first level for every property loaded from the Parameter Store. + Value must start with a forward slash followed by one or more valid path segments or be empty.

aws.paramstore.defaultContext

application

Name of the context that defines properties shared across all services

aws.paramstore.profileSeparator

_

String that separates an appended profile from the context name. Note that an AWS parameter key can only contain + dots, dashes and underscores next to alphanumeric characters.

aws.paramstore.failFast

true

Indicates if an error while retrieving the parameters should fail starting the application.

aws.paramstore.name

the configured value for spring.application.name

Name to use when constructing the path for the properties to look up for this specific service.

aws.paramstore.enabled

true

Can be used to disable the Parameter Store Configuration support even though the auto-configuration is on the classpath.

\ No newline at end of file diff --git a/spring-cloud-aws/2.0.0.RC2/multi/multi__using_amazon_web_services.html b/spring-cloud-aws/2.0.0.RC2/multi/multi__using_amazon_web_services.html index 782eb6f0..9115ecf4 100644 --- a/spring-cloud-aws/2.0.0.RC2/multi/multi__using_amazon_web_services.html +++ b/spring-cloud-aws/2.0.0.RC2/multi/multi__using_amazon_web_services.html @@ -14,4 +14,5 @@ resource loader abstraction. Moreover developers can send e-mails using the ElastiCache caching service.
  • Spring Cloud AWS JDBC provides automatic datasource lookup and configuration for the Relational Database Service which can be used with JDBC or any other support data access technology by Spring.
  • Spring Cloud AWS Messaging enables developers to receive and send messages with the Simple Queueing Service for -point-to-point communication. Publish-subscribe messaging is supported with the integration of the Simple Notification Service.
  • \ No newline at end of file +point-to-point communication. Publish-subscribe messaging is supported with the integration of the Simple Notification Service.
  • Spring Cloud AWS Parameter Store Configuration enables Spring Cloud applications to use the AWS Parameter Store +as a Bootstrap Property Source, comparable to the support provided for the Spring Cloud Config Server or Consul’s key-value store.
  • \ No newline at end of file diff --git a/spring-cloud-aws/2.0.0.RC2/multi/multi_spring-cloud-aws.html b/spring-cloud-aws/2.0.0.RC2/multi/multi_spring-cloud-aws.html index 6d1f1014..a0951ae0 100644 --- a/spring-cloud-aws/2.0.0.RC2/multi/multi_spring-cloud-aws.html +++ b/spring-cloud-aws/2.0.0.RC2/multi/multi_spring-cloud-aws.html @@ -1,3 +1,3 @@ - Spring Cloud AWS

    Spring Cloud AWS

    Authors

    Agim Emruli, Alain Sahli

    Table of Contents

    1. Using Amazon Web Services
    2. Basic setup
    2.1. Spring Cloud AWS maven dependency management
    2.2. Amazon SDK configuration
    2.2.1. SDK credentials configuration
    Simple credentials configuration
    Instance profile configuration
    Mixing both security configurations
    2.2.2. Region configuration
    Explicit region configuration
    Automatic region configuration
    Service specific region configuration
    2.2.3. Spring Boot auto-configuration
    Maven dependencies
    Configuring credentials
    Configuring region
    3. Cloud environment
    3.1. Retrieving instance metadata
    3.1.1. Enabling instance metadata support with XML
    3.1.2. Enabling instance metadata support with Java
    3.1.3. Enabling instance metadata support in Spring Boot
    3.1.4. Using instance metadata
    3.1.5. Using instance user data
    3.1.6. Using instance tags
    3.1.7. Configuring custom EC2 client
    3.1.8. Injecting the default EC2 client
    4. Managing cloud environments
    4.1. Automatic CloudFormation configuration
    4.2. Manual CloudFormation configuration
    4.3. CloudFormation configuration with Java config classes
    4.4. CloudFormation configuration in Spring Boot
    4.5. Manual name resolution
    4.6. Stack Tags
    4.7. Using custom CloudFormation client
    5. Messaging
    5.1. Configuring messaging
    5.1.1. Maven dependency configuration
    5.2. SQS support
    5.2.1. Sending a message
    Using message converters
    5.2.2. Receiving a message
    5.2.3. Annotation-driven listener endpoints
    Message reply
    5.2.4. The SimpleMessageListenerContainerFactory
    5.2.5. Consuming AWS Event messages with Amazon SQS
    5.3. SNS support
    5.3.1. Sending a message
    5.3.2. Annotation-driven HTTP notification endpoint
    5.4. Using CloudFormation
    6. Caching
    6.1. Configuring dependencies for Redis caches
    6.2. Configuring caching with XML
    6.2.1. Mixing caches
    6.2.2. Defining expiration
    6.3. Configuring caching using Java configuration
    6.3.1. Configuring expiry time for caches
    6.4. Configuring caching in Spring Boot
    6.5. Using caching
    6.6. Memcached client implementation
    6.7. Using CloudFormation
    7. Data Access with JDBC
    7.1. Configuring data source
    7.1.1. Maven dependency configuration
    7.1.2. Basic data source configuration
    7.1.3. Data source pool configuration
    7.2. Configuring data source with Java config
    7.2.1. Java based data source pool configuration
    7.3. Configuring data source in Spring Boot
    7.4. Read-replica configuration
    7.5. Failover support
    7.6. CloudFormation support
    7.7. Database tags
    8. Sending mails
    8.1. Configuring the mail sender
    8.2. Sending simple mails
    8.3. Sending attachments
    8.4. Configuring regions
    8.5. Authenticating e-mails
    9. Resource handling
    9.1. Configuring the resource loader
    9.2. Downloading files
    9.3. Uploading files
    9.3.1. Uploading multi-part files
    9.3.2. Uploading with the TransferManager
    9.4. Searching resources
    9.5. Using CloudFormation
    \ No newline at end of file + Spring Cloud AWS

    Spring Cloud AWS

    Authors

    Agim Emruli, Alain Sahli

    Table of Contents

    1. Using Amazon Web Services
    2. Basic setup
    2.1. Spring Cloud AWS maven dependency management
    2.2. Amazon SDK configuration
    2.2.1. SDK credentials configuration
    Simple credentials configuration
    Instance profile configuration
    Mixing both security configurations
    Parameter Store Configuration credentials and region configuration
    2.2.2. Region configuration
    Explicit region configuration
    Automatic region configuration
    Service specific region configuration
    2.2.3. Spring Boot auto-configuration
    Maven dependencies
    Configuring credentials
    Configuring region
    3. Cloud environment
    3.1. Retrieving instance metadata
    3.1.1. Enabling instance metadata support with XML
    3.1.2. Enabling instance metadata support with Java
    3.1.3. Enabling instance metadata support in Spring Boot
    3.1.4. Using instance metadata
    3.1.5. Using instance user data
    3.1.6. Using instance tags
    3.1.7. Configuring custom EC2 client
    3.1.8. Injecting the default EC2 client
    3.2. Integrating your Spring Cloud application with the AWS Parameter Store
    4. Managing cloud environments
    4.1. Automatic CloudFormation configuration
    4.2. Manual CloudFormation configuration
    4.3. CloudFormation configuration with Java config classes
    4.4. CloudFormation configuration in Spring Boot
    4.5. Manual name resolution
    4.6. Stack Tags
    4.7. Using custom CloudFormation client
    5. Messaging
    5.1. Configuring messaging
    5.1.1. Maven dependency configuration
    5.2. SQS support
    5.2.1. Sending a message
    Using message converters
    5.2.2. Receiving a message
    5.2.3. Annotation-driven listener endpoints
    Message reply
    5.2.4. The SimpleMessageListenerContainerFactory
    5.2.5. Consuming AWS Event messages with Amazon SQS
    5.3. SNS support
    5.3.1. Sending a message
    5.3.2. Annotation-driven HTTP notification endpoint
    5.4. Using CloudFormation
    6. Caching
    6.1. Configuring dependencies for Redis caches
    6.2. Configuring caching with XML
    6.2.1. Mixing caches
    6.2.2. Defining expiration
    6.3. Configuring caching using Java configuration
    6.3.1. Configuring expiry time for caches
    6.4. Configuring caching in Spring Boot
    6.5. Using caching
    6.6. Memcached client implementation
    6.7. Using CloudFormation
    7. Data Access with JDBC
    7.1. Configuring data source
    7.1.1. Maven dependency configuration
    7.1.2. Basic data source configuration
    7.1.3. Data source pool configuration
    7.2. Configuring data source with Java config
    7.2.1. Java based data source pool configuration
    7.3. Configuring data source in Spring Boot
    7.4. Read-replica configuration
    7.5. Failover support
    7.6. CloudFormation support
    7.7. Database tags
    8. Sending mails
    8.1. Configuring the mail sender
    8.2. Sending simple mails
    8.3. Sending attachments
    8.4. Configuring regions
    8.5. Authenticating e-mails
    9. Resource handling
    9.1. Configuring the resource loader
    9.2. Downloading files
    9.3. Uploading files
    9.3.1. Uploading multi-part files
    9.3.2. Uploading with the TransferManager
    9.4. Searching resources
    9.5. Using CloudFormation
    \ No newline at end of file diff --git a/spring-cloud-aws/2.0.0.RC2/single/spring-cloud-aws.html b/spring-cloud-aws/2.0.0.RC2/single/spring-cloud-aws.html index 73c55e19..a9c02bd5 100644 --- a/spring-cloud-aws/2.0.0.RC2/single/spring-cloud-aws.html +++ b/spring-cloud-aws/2.0.0.RC2/single/spring-cloud-aws.html @@ -1,6 +1,6 @@ - Spring Cloud AWS

    Spring Cloud AWS

    Authors

    Agim Emruli, Alain Sahli

    Table of Contents

    1. Using Amazon Web Services
    2. Basic setup
    2.1. Spring Cloud AWS maven dependency management
    2.2. Amazon SDK configuration
    2.2.1. SDK credentials configuration
    Simple credentials configuration
    Instance profile configuration
    Mixing both security configurations
    2.2.2. Region configuration
    Explicit region configuration
    Automatic region configuration
    Service specific region configuration
    2.2.3. Spring Boot auto-configuration
    Maven dependencies
    Configuring credentials
    Configuring region
    3. Cloud environment
    3.1. Retrieving instance metadata
    3.1.1. Enabling instance metadata support with XML
    3.1.2. Enabling instance metadata support with Java
    3.1.3. Enabling instance metadata support in Spring Boot
    3.1.4. Using instance metadata
    3.1.5. Using instance user data
    3.1.6. Using instance tags
    3.1.7. Configuring custom EC2 client
    3.1.8. Injecting the default EC2 client
    4. Managing cloud environments
    4.1. Automatic CloudFormation configuration
    4.2. Manual CloudFormation configuration
    4.3. CloudFormation configuration with Java config classes
    4.4. CloudFormation configuration in Spring Boot
    4.5. Manual name resolution
    4.6. Stack Tags
    4.7. Using custom CloudFormation client
    5. Messaging
    5.1. Configuring messaging
    5.1.1. Maven dependency configuration
    5.2. SQS support
    5.2.1. Sending a message
    Using message converters
    5.2.2. Receiving a message
    5.2.3. Annotation-driven listener endpoints
    Message reply
    5.2.4. The SimpleMessageListenerContainerFactory
    5.2.5. Consuming AWS Event messages with Amazon SQS
    5.3. SNS support
    5.3.1. Sending a message
    5.3.2. Annotation-driven HTTP notification endpoint
    5.4. Using CloudFormation
    6. Caching
    6.1. Configuring dependencies for Redis caches
    6.2. Configuring caching with XML
    6.2.1. Mixing caches
    6.2.2. Defining expiration
    6.3. Configuring caching using Java configuration
    6.3.1. Configuring expiry time for caches
    6.4. Configuring caching in Spring Boot
    6.5. Using caching
    6.6. Memcached client implementation
    6.7. Using CloudFormation
    7. Data Access with JDBC
    7.1. Configuring data source
    7.1.1. Maven dependency configuration
    7.1.2. Basic data source configuration
    7.1.3. Data source pool configuration
    7.2. Configuring data source with Java config
    7.2.1. Java based data source pool configuration
    7.3. Configuring data source in Spring Boot
    7.4. Read-replica configuration
    7.5. Failover support
    7.6. CloudFormation support
    7.7. Database tags
    8. Sending mails
    8.1. Configuring the mail sender
    8.2. Sending simple mails
    8.3. Sending attachments
    8.4. Configuring regions
    8.5. Authenticating e-mails
    9. Resource handling
    9.1. Configuring the resource loader
    9.2. Downloading files
    9.3. Uploading files
    9.3.1. Uploading multi-part files
    9.3.2. Uploading with the TransferManager
    9.4. Searching resources
    9.5. Using CloudFormation

    Spring Cloud for Amazon Web Services, part of the Spring Cloud umbrella project, eases the integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application around the hosted services without having to care about infrastructure or maintenance.

    [Note]Note

    Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github.

    1. Using Amazon Web Services

    Amazon provides a Java SDK to issue requests for the all services provided by the + Spring Cloud AWS

    Spring Cloud AWS

    Authors

    Agim Emruli, Alain Sahli

    Table of Contents

    1. Using Amazon Web Services
    2. Basic setup
    2.1. Spring Cloud AWS maven dependency management
    2.2. Amazon SDK configuration
    2.2.1. SDK credentials configuration
    Simple credentials configuration
    Instance profile configuration
    Mixing both security configurations
    Parameter Store Configuration credentials and region configuration
    2.2.2. Region configuration
    Explicit region configuration
    Automatic region configuration
    Service specific region configuration
    2.2.3. Spring Boot auto-configuration
    Maven dependencies
    Configuring credentials
    Configuring region
    3. Cloud environment
    3.1. Retrieving instance metadata
    3.1.1. Enabling instance metadata support with XML
    3.1.2. Enabling instance metadata support with Java
    3.1.3. Enabling instance metadata support in Spring Boot
    3.1.4. Using instance metadata
    3.1.5. Using instance user data
    3.1.6. Using instance tags
    3.1.7. Configuring custom EC2 client
    3.1.8. Injecting the default EC2 client
    3.2. Integrating your Spring Cloud application with the AWS Parameter Store
    4. Managing cloud environments
    4.1. Automatic CloudFormation configuration
    4.2. Manual CloudFormation configuration
    4.3. CloudFormation configuration with Java config classes
    4.4. CloudFormation configuration in Spring Boot
    4.5. Manual name resolution
    4.6. Stack Tags
    4.7. Using custom CloudFormation client
    5. Messaging
    5.1. Configuring messaging
    5.1.1. Maven dependency configuration
    5.2. SQS support
    5.2.1. Sending a message
    Using message converters
    5.2.2. Receiving a message
    5.2.3. Annotation-driven listener endpoints
    Message reply
    5.2.4. The SimpleMessageListenerContainerFactory
    5.2.5. Consuming AWS Event messages with Amazon SQS
    5.3. SNS support
    5.3.1. Sending a message
    5.3.2. Annotation-driven HTTP notification endpoint
    5.4. Using CloudFormation
    6. Caching
    6.1. Configuring dependencies for Redis caches
    6.2. Configuring caching with XML
    6.2.1. Mixing caches
    6.2.2. Defining expiration
    6.3. Configuring caching using Java configuration
    6.3.1. Configuring expiry time for caches
    6.4. Configuring caching in Spring Boot
    6.5. Using caching
    6.6. Memcached client implementation
    6.7. Using CloudFormation
    7. Data Access with JDBC
    7.1. Configuring data source
    7.1.1. Maven dependency configuration
    7.1.2. Basic data source configuration
    7.1.3. Data source pool configuration
    7.2. Configuring data source with Java config
    7.2.1. Java based data source pool configuration
    7.3. Configuring data source in Spring Boot
    7.4. Read-replica configuration
    7.5. Failover support
    7.6. CloudFormation support
    7.7. Database tags
    8. Sending mails
    8.1. Configuring the mail sender
    8.2. Sending simple mails
    8.3. Sending attachments
    8.4. Configuring regions
    8.5. Authenticating e-mails
    9. Resource handling
    9.1. Configuring the resource loader
    9.2. Downloading files
    9.3. Uploading files
    9.3.1. Uploading multi-part files
    9.3.2. Uploading with the TransferManager
    9.4. Searching resources
    9.5. Using CloudFormation

    Spring Cloud for Amazon Web Services, part of the Spring Cloud umbrella project, eases the integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application around the hosted services without having to care about infrastructure or maintenance.

    [Note]Note

    Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github.

    1. Using Amazon Web Services

    Amazon provides a Java SDK to issue requests for the all services provided by the Amazon Web Service platform. Using the SDK, application developers still have to integrate the SDK into their application with a considerable amount of infrastructure related code. Spring Cloud AWS provides application developers already integrated Spring-based modules to consume services and avoid infrastructure related code as much as possible. @@ -14,7 +14,8 @@ resource loader abstraction. Moreover developers can send e-mails using the ElastiCache caching service.

  • Spring Cloud AWS JDBC provides automatic datasource lookup and configuration for the Relational Database Service which can be used with JDBC or any other support data access technology by Spring.
  • Spring Cloud AWS Messaging enables developers to receive and send messages with the Simple Queueing Service for -point-to-point communication. Publish-subscribe messaging is supported with the integration of the Simple Notification Service.
  • 2. Basic setup

    Before using the Spring Cloud AWS module developers have to pick the dependencies and configure the Spring Cloud AWS module. +point-to-point communication. Publish-subscribe messaging is supported with the integration of the Simple Notification Service.

  • Spring Cloud AWS Parameter Store Configuration enables Spring Cloud applications to use the AWS Parameter Store +as a Bootstrap Property Source, comparable to the support provided for the Spring Cloud Config Server or Consul’s key-value store.
  • 2. Basic setup

    Before using the Spring Cloud AWS module developers have to pick the dependencies and configure the Spring Cloud AWS module. The next chapters describe the dependency management and also the basic configuration for the Spring AWS Cloud project.

    2.1 Spring Cloud AWS maven dependency management

    Spring Cloud AWS module dependencies can be used directly in Maven with a direct configuration of the particular module. The Spring Cloud AWS module includes all transitive dependencies for the Spring modules and also the Amazon SDK that are needed to operate the modules. The general dependency configuration will look like this:

    <dependencies>
    @@ -51,9 +52,9 @@ use of the modules. A typical XML configuration to use Spring Cloud AWS is outli
                <aws-context:context-region region="..."/>
     </beans>

    2.2.1 SDK credentials configuration

    In order to make calls to the Amazon Web Service the credentials must be configured for the the Amazon SDK. Spring Cloud AWS provides support to configure an application context specific credentials that are used for each service call for requests done -by Spring Cloud AWS components. Therefore there must be exactly one configuration of the credentials for an entire application -context.

    [Tip]Tip

    The com.amazonaws.auth.DefaultAWSCredentialsProviderChain is used by all the clients if there is no dedicated credentials - provider defined. This will essentially use the following authentication information

    • use the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
    • use the system properties aws.accessKeyId and aws.secretKey
    • use the user specific profile credentials file
    • use the instance profile credentials (see below)

    Based on the overall credentials policy there are different options to configure the credentials. The possible ones are described in +by Spring Cloud AWS components, with the exception of the Parameter Store Configuration. +Therefore there must be exactly one configuration of the credentials for an entire application context.

    [Tip]Tip

    The com.amazonaws.auth.DefaultAWSCredentialsProviderChain is used by all the clients if there is no dedicated credentials + provider defined. This will essentially use the following authentication information

    • use the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
    • use the system properties aws.accessKeyId and aws.secretKey
    • use the user specific profile credentials file
    • use ECS credentials if the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable is set
    • use the instance profile credentials (see below)

    Based on the overall credentials policy there are different options to configure the credentials. The possible ones are described in the following sub-chapters.

    Simple credentials configuration

    Credentials for the Amazon SDK consist of an access key (which might be shared) and a secret key (which must not be shared). Both security attributes can be configured using the XML namespaces for each Amazon SDK service created by the Spring Cloud AWS module. The overall configuration looks like this

    <beans ...>
    @@ -76,7 +77,13 @@ EC2 (e.g. on a test server) and locally for testing. The next snippet shows a co
            <aws-context:simple-credentials access-key="${accessKey:}" secret-key="${secretKey:}"/>
        </aws-context:context-credentials>
     </beans>
    [Tip]Tip

    The access-key and secret-key are defined using a placeholder expressions along with a default value to avoid bootstrap -errors if the properties are not configured at all.

    2.2.2 Region configuration

    Amazon Web services are available in different regions. Based +errors if the properties are not configured at all.

    Parameter Store Configuration credentials and region configuration

    The Parameter Store Configuration support uses a bootstrap context to configure a default AWSSimpleSystemsManagement +client, which uses a com.amazonaws.auth.DefaultAWSCredentialsProviderChain and com.amazonaws.regions.DefaultAwsRegionProviderChain. +If you want to override this, then you need to +define your own Spring Cloud bootstrap configuration class +with a bean of type AWSSimpleSystemsManagement that’s configured to use your chosen credentials and/or region provider. +Because this context is created when your Spring Cloud Bootstrap context is created, you can’t simply override the bean +in a regular @Configuration class.

    2.2.2 Region configuration

    Amazon Web services are available in different regions. Based on the custom requirements, the user can host the application on different Amazon regions. The spring-cloud-aws-context module provides a way to define the region for the entire application context.

    Explicit region configuration

    The region can be explicitly configured using an XML element. This is particularly useful if the region can not be automatically derived because the application is not hosted on a EC2 instance (e.g. local testing) or the region must be manually overridden.

    <beans ...>
    @@ -243,7 +250,21 @@ the specified region and security credentials. Application developers can inject
     	public ApplicationService(AmazonEC2 amazonEc2) {
     		this.amazonEc2 = amazonEc2;
     	}
    -}

    4. Managing cloud environments

    Managing environments manually with the management console does not scale and can become error-prone with the increasing +}

    3.2 Integrating your Spring Cloud application with the AWS Parameter Store

    Spring Cloud provides support for centralized configuration, which can be read and made available as a regular Spring +PropertySource when the application is started. The Parameter Store Configuration allows you to use this mechanism +with the AWS Parameter Store.

    Simply add a dependency on the spring-cloud-starter-aws-parameter-store-config starter module to activate the support. +The support is similar to the support provided for the Spring Cloud Config Server or Consul’s key-value store: +configuration parameters can be defined to be shared across all services or for a specific service and can be +profile-specific. Encrypted values will be decrypted when retrieved.

    All configuration parameters are retrieved from a common path prefix, which defaults to /config. From there shared +parameters are retrieved from a path that defaults to application and service-specific parameters use a path that +defaults to the configured spring.application.name. You can use both dots and forward slashes to specify the names +of configuration keys. Names of activated profiles will be appended to the path using a separator that defaults to an +underscore.

    That means that for a service called my-service the module by default would find and use these parameters:

    parameter keySpring propertydescription

    /config/application/cloud.aws.stack.name

    cloud.aws.stack.name

    Shared by all services that have the Configuration support enabled. Can be overridden with a service- or profile-specific property.

    /config/application_production/cloud.aws.stack.name

    cloud.aws.stack.name

    Shared by all services that have the Configuration support enabled and have a production Spring profile activated. + Can be overridden with a service-specific property.

    /config/my-service/cloud/aws/stack/auto

    cloud.aws.stack.auto

    Specific to the my-service service. Note that slashes in the key path are replaced with dots.

    /config/my-service_production/cloud/aws/stack/auto

    cloud.aws.stack.auto

    Specific to the my-service service when a production Spring profile is activated.

    Note that this module does not support full configuration files to be used as parameter values like e.g. Spring Cloud Consul does: +AWS parameter values are limited to 4096 characters, so we support individual Spring properties to be configured only.

    You can configure the following settings in a Spring Cloud bootstrap.properties or bootstrap.yml file +(note that relaxed property binding is applied, so you don’t have to use this exact syntax):

    propertydefaultexplanation

    aws.paramstore.prefix

    /config

    Prefix indicating first level for every property loaded from the Parameter Store. + Value must start with a forward slash followed by one or more valid path segments or be empty.

    aws.paramstore.defaultContext

    application

    Name of the context that defines properties shared across all services

    aws.paramstore.profileSeparator

    _

    String that separates an appended profile from the context name. Note that an AWS parameter key can only contain + dots, dashes and underscores next to alphanumeric characters.

    aws.paramstore.failFast

    true

    Indicates if an error while retrieving the parameters should fail starting the application.

    aws.paramstore.name

    the configured value for spring.application.name

    Name to use when constructing the path for the properties to look up for this specific service.

    aws.paramstore.enabled

    true

    Can be used to disable the Parameter Store Configuration support even though the auto-configuration is on the classpath.

    4. Managing cloud environments

    Managing environments manually with the management console does not scale and can become error-prone with the increasing complexity of the infrastructure. Amazon Web services offers a CloudFormation service that allows to define stack configuration templates and bootstrap the whole infrastructure with the services. In order to allow multiple stacks in parallel, each resource in the stack receives a unique physical name that contains diff --git a/spring-cloud-aws/2.0.0.RC2/spring-cloud-aws.xml b/spring-cloud-aws/2.0.0.RC2/spring-cloud-aws.xml index 3a4b7e4a..72c3ab51 100644 --- a/spring-cloud-aws/2.0.0.RC2/spring-cloud-aws.xml +++ b/spring-cloud-aws/2.0.0.RC2/spring-cloud-aws.xml @@ -4,7 +4,7 @@ Spring Cloud AWS -2018-05-24 +2018-06-06 @@ -65,6 +65,10 @@ which can be used with JDBC or any other support data access technology by Sprin Spring Cloud AWS Messaging enables developers to receive and send messages with the Simple Queueing Service for point-to-point communication. Publish-subscribe messaging is supported with the integration of the Simple Notification Service. + +Spring Cloud AWS Parameter Store Configuration enables Spring Cloud applications to use the AWS Parameter Store +as a Bootstrap Property Source, comparable to the support provided for the Spring Cloud Config Server or Consul’s key-value store. + @@ -123,8 +127,8 @@ use of the modules. A typical XML configuration to use Spring Cloud AWS is outli SDK credentials configuration In order to make calls to the Amazon Web Service the credentials must be configured for the the Amazon SDK. Spring Cloud AWS provides support to configure an application context specific credentials that are used for each service call for requests done -by Spring Cloud AWS components. Therefore there must be exactly one configuration of the credentials for an entire application -context. +by Spring Cloud AWS components, with the exception of the Parameter Store Configuration. +Therefore there must be exactly one configuration of the credentials for an entire application context. The com.amazonaws.auth.DefaultAWSCredentialsProviderChain is used by all the clients if there is no dedicated credentials provider defined. This will essentially use the following authentication information @@ -139,6 +143,9 @@ context. use the user specific profile credentials file +use ECS credentials if the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable is set + + use the instance profile credentials (see below) @@ -188,6 +195,16 @@ EC2 (e.g. on a test server) and locally for testing. The next snippet shows a co errors if the properties are not configured at all. +

    +Parameter Store Configuration credentials and region configuration +The Parameter Store Configuration support uses a bootstrap context to configure a default AWSSimpleSystemsManagement +client, which uses a com.amazonaws.auth.DefaultAWSCredentialsProviderChain and com.amazonaws.regions.DefaultAwsRegionProviderChain. +If you want to override this, then you need to +define your own Spring Cloud bootstrap configuration class +with a bean of type AWSSimpleSystemsManagement that’s configured to use your chosen credentials and/or region provider. +Because this context is created when your Spring Cloud Bootstrap context is created, you can’t simply override the bean +in a regular @Configuration class. +
    Region configuration @@ -547,6 +564,111 @@ the specified region and security credentials. Application developers can inject }
    +
    +Integrating your Spring Cloud application with the AWS Parameter Store +Spring Cloud provides support for centralized configuration, which can be read and made available as a regular Spring +PropertySource when the application is started. The Parameter Store Configuration allows you to use this mechanism +with the AWS Parameter Store. +Simply add a dependency on the spring-cloud-starter-aws-parameter-store-config starter module to activate the support. +The support is similar to the support provided for the Spring Cloud Config Server or Consul’s key-value store: +configuration parameters can be defined to be shared across all services or for a specific service and can be +profile-specific. Encrypted values will be decrypted when retrieved. +All configuration parameters are retrieved from a common path prefix, which defaults to /config. From there shared +parameters are retrieved from a path that defaults to application and service-specific parameters use a path that +defaults to the configured spring.application.name. You can use both dots and forward slashes to specify the names +of configuration keys. Names of activated profiles will be appended to the path using a separator that defaults to an +underscore. +That means that for a service called my-service the module by default would find and use these parameters: + + + + + + + +parameter key +Spring property +description + + + + +/config/application/cloud.aws.stack.name +cloud.aws.stack.name +Shared by all services that have the Configuration support enabled. Can be overridden with a service- or profile-specific property. + + +/config/application_production/cloud.aws.stack.name +cloud.aws.stack.name +Shared by all services that have the Configuration support enabled and have a production Spring profile activated. + Can be overridden with a service-specific property. + + +/config/my-service/cloud/aws/stack/auto +cloud.aws.stack.auto +Specific to the my-service service. Note that slashes in the key path are replaced with dots. + + +/config/my-service_production/cloud/aws/stack/auto +cloud.aws.stack.auto +Specific to the my-service service when a production Spring profile is activated. + + + + +Note that this module does not support full configuration files to be used as parameter values like e.g. Spring Cloud Consul does: +AWS parameter values are limited to 4096 characters, so we support individual Spring properties to be configured only. +You can configure the following settings in a Spring Cloud bootstrap.properties or bootstrap.yml file +(note that relaxed property binding is applied, so you don’t have to use this exact syntax): + + + + + + + +property +default +explanation + + + + +aws.paramstore.prefix +/config +Prefix indicating first level for every property loaded from the Parameter Store. + Value must start with a forward slash followed by one or more valid path segments or be empty. + + +aws.paramstore.defaultContext +application +Name of the context that defines properties shared across all services + + +aws.paramstore.profileSeparator +_ +String that separates an appended profile from the context name. Note that an AWS parameter key can only contain + dots, dashes and underscores next to alphanumeric characters. + + +aws.paramstore.failFast +true +Indicates if an error while retrieving the parameters should fail starting the application. + + +aws.paramstore.name +the configured value for spring.application.name +Name to use when constructing the path for the properties to look up for this specific service. + + +aws.paramstore.enabled +true +Can be used to disable the Parameter Store Configuration support even though the auto-configuration is on the classpath. + + + + +
    Managing cloud environments