Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何在CloudFormation中将DynamoDB表地址、Redis端口和地址传递给我的EC2实例?_Amazon Web Services_Amazon Ec2_Amazon Dynamodb_Amazon Cloudformation - Fatal编程技术网

Amazon web services 如何在CloudFormation中将DynamoDB表地址、Redis端口和地址传递给我的EC2实例?

Amazon web services 如何在CloudFormation中将DynamoDB表地址、Redis端口和地址传递给我的EC2实例?,amazon-web-services,amazon-ec2,amazon-dynamodb,amazon-cloudformation,Amazon Web Services,Amazon Ec2,Amazon Dynamodb,Amazon Cloudformation,我有一个系统需要一个EC2实例,该实例连接到DynamoDB表和Redis实例。如何使用YAML在CloudFormation中将这些设置为我的EC2实例的选项 我已经创建了OptionSettings,将这些值设置为EC2实例上进程的环境变量。我知道我需要去做!参考[此处的内容],但文档中没有对我有意义的示例 下面是代码的简化版本: --- AWSTemplateFormatVersion: "2010-09-09" Description: CloudFormation template

我有一个系统需要一个EC2实例,该实例连接到DynamoDB表和Redis实例。如何使用YAML在CloudFormation中将这些设置为我的EC2实例的选项

我已经创建了OptionSettings,将这些值设置为EC2实例上进程的环境变量。我知道我需要去做!参考[此处的内容],但文档中没有对我有意义的示例

下面是代码的简化版本:

---
AWSTemplateFormatVersion: "2010-09-09"

Description: CloudFormation template

Resources:
  # Beanstalk application
  MyApp:
    Type: AWS::ElasticBeanstalk::Application
  ConfigurationTemplate:
    Type: AWS::ElasticBeanstalk::ConfigurationTemplate
    Properties:
      ApplicationName: !Ref MyApp
      OptionSettings:
      - Namespace: "aws:elasticbeanstalk:application:environment"
        OptionName: REDIS_CACHE_PORT
        Value: !Ref AttributeCache.Port # Should be 6379
      - Namespace: "aws:elasticbeanstalk:application:environment"
        OptionName: REDIS_CACHE_ADDRESS
        Value: !Ref MyCache. # Something that AWS creates
      - Namespace: "aws:elasticbeanstalk:application:environment"
        OptionName: DYNAMODB_TABLE_ADDRESS
        Value: !Ref MyDynamoTable. # Something that AWS creates
      SolutionStackName: 64bit Amazon Linux 2018.03 v4.8.1 running Node.js

  # Redis cache
  MyCache:
    Type: AWS::ElastiCache::CacheCluster
    Properties:
      ClusterName: MyCacheCluster
      Engine: redis
      EngineVersion: 4.0.10
      NumCacheNodes: 1
      Port: 6379

  # DynamoDB table
  MyDynamoTable:
    Type: "AWS::DynamoDB::Table"
    Properties:
      AttributeDefinitions:
      - AttributeName: theAttributeName
        AttributeType: S
      KeySchema:
      - AttributeName: theAttributeName
        KeyType: HASH
      TableName: myDynamoTable
我不确定如何访问CloudFormation将创建的东西。 是Ref正确,或者我需要!取而代之的是盖塔特

以下是指向两个不同功能文档的链接


即使只是指出我缺少的东西也会有所帮助。

这类信息在每项服务的文档部分中都有详细说明。此文档部分还提供了您是否必须使用
的信息!参考
!GetAtt
以检索特定参数。例如,您必须使用
!GetAtt MyCache.RedisEndpoint.Port
获取redis的端口,并说您必须使用
!请参考MyDynamoTable
以获取表名

选项设置:
-命名空间:“aws:elasticbeanstalk:application:environment”
选项名称:REDIS\u缓存\u端口
值:!GetAtt MyCache.RedisEndpoint.Port
-命名空间:“aws:elasticbeanstalk:application:environment”
选项名称:REDIS\u缓存\u地址
值:!GetAtt MyCache.RedisEndpoint.Address
-命名空间:“aws:elasticbeanstalk:application:environment”
选项名称:发电机表地址
值:!Ref MyDynamoTable#这一个你做对了,但最后没有点