小编Ped*_*tes的帖子

如何在CloudFormation上将DynamoDB读/写容量模式设置为按需

我已经看过这个关于DynamoDB On-demand的网站,我将我的表格(由CloudFormation创建)更新为按需.现在,当我尝试更新我的堆栈时,我收到此错误:

一个或多个参数值无效:当BillingMode为PAY_PER_REQUEST时,无法指定ReadCapacityUnits和WriteCapacityUnits

有没有办法在CloudFormation上将DynamoDB读/写容量模式设置为按需?

编辑:

我已在AWS Console上更新为按需.

编辑2:

我的模板:

DynamoDBUsersTable:
    Type: AWS::DynamoDB::Table
    Description: Users table
    Properties:
      TableName: !Sub ${StackName}-users-table
      AttributeDefinitions:
        - AttributeName: userId
          AttributeType: S
      KeySchema:
        - AttributeName: userId
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 10
        WriteCapacityUnits: 10
Run Code Online (Sandbox Code Playgroud)

谢谢.

amazon-web-services aws-cloudformation amazon-dynamodb

13
推荐指数
1
解决办法
4266
查看次数

AWS CodeBuild 不适用于 Yarn 工作区

我在我的存储库中使用 Yarn Workspaces 并使用 AWS CodeBuild 来构建我的包。构建开始时,CodeBuild 需要 60 秒来安装所有包,我想避免这次缓存node_modules文件夹。

当我添加:

cache:
  paths:
    - 'node_modules/**/*'
Run Code Online (Sandbox Code Playgroud)

到我的buildspec文件并启用LOCAL_CUSTOM_CACHE,我收到此错误:

错误发生意外错误:“EEXIST:文件已存在,mkdir '/codebuild/output/src637134264/src/git-codecommit.us-east-2.amazonaws.com/v1/repos/MY_REPOSITORY/node_modules/@packages/configs '”。

有没有办法消除配置 AWS CodeBuild 或 Yarn 的错误?

我的构建规范文件:

version: 0.2
phases:
  install:
    commands:
      - npm install -g yarn
      - git config --global credential.helper '!aws codecommit credential-helper $@'
      - git config --global credential.UseHttpPath true
      - yarn
  pre_build:
    commands:
      - git rev-parse HEAD
      - git pull origin master
  build:
    commands:
      - yarn run build
      - yarn run deploy …
Run Code Online (Sandbox Code Playgroud)

yarnpkg aws-codebuild yarn-workspaces

12
推荐指数
1
解决办法
2739
查看次数

尝试从 aws-appsync lib 修复“找不到模块的声明文件”会导致另一个错误

我正在使用aws-appsync库,但出现此错误:

(4,42): 找不到模块“@redux-offline/redux-offline/lib/types”的声明文件。'node_modules/aws-appsync/node_modules/@redux-offline/redux-offline/lib/types.js' 隐式具有 'any' 类型。尝试npm install @types/redux-offline__redux-offline它是否存在或添加一个新的声明 (.d.ts) 文件,其中包含declare module '@redux-offline/redux-offline/lib/types';

然后我添加declare module @redux-offline/redux-offline/lib/types;到我的typings.d.ts以检查该错误是否消失,但我得到了其他:

/node_modules/aws-appsync/lib/store.d.ts (13,69):不能使用命名空间“NetworkCallback”作为类型。

现在我不知道如何修复最后一个错误,因为我没有在互联网上找到很多关于它的信息。

我不知道这是否重要,但它packages/web/node_modules/@redux-offline/redux-offline/lib/types.js是一个只有"use strict";行的文件。

一个有效的解决方案是 setting noImplicitAny: false,但我已经阅读过它并且它不是一个好的解决方案。

谢谢!

typescript reactjs typescript-typings

6
推荐指数
1
解决办法
2054
查看次数

如何使用 rollup.js 将自定义打字稿声明文件添加到最终构建中?

我在 Typescript 中有一个项目,其中文件是使用 rollup.js 构建的。在我的项目中,我定义了一些声明文件,我想知道是否可以将这些声明文件添加到最终构建的声明文件中。

声明文件:

// src/styled-components.d.ts

import 'styled-components';

declare module 'styled-components' {
    export interface DefaultTheme {
        colors: {
            gray: string;
            primary: string;
        };
    }
}

Run Code Online (Sandbox Code Playgroud)

我当前的最终构建声明文件:

// dist/index.d.ts

export { default as DesignSystemProvider, } from './providers/DesignSystemProvider';
export { default as Button } from './components/Button';
export { default as Checkbox } from './components/Checkbox';
Run Code Online (Sandbox Code Playgroud)

预期的最终构建声明文件:

// dist/index.d.ts

import 'styled-components';

declare module 'styled-components' {
    export interface DefaultTheme {
        colors: {
            gray: string;
            primary: string;
        };
    }
}

export { default as …
Run Code Online (Sandbox Code Playgroud)

typescript rollupjs typescript-typings

6
推荐指数
1
解决办法
1393
查看次数

如何使用自定义联合身份访问 AppSync API

我尝试使用具有自定义身份验证角色的联合身份来使用 AWS AppSync API,但没有成功。

首先,我按照本教程创建了我的客户端。然后我打开 Federated Identities 控制台 -> 编辑身份池 -> 自定义并创建一个Developer provider name:login.mycompany.myapp并选中Enable access to unauthenticated identities

之后,我按照此了解如何创建自定义身份验证。

从后端获取身份 ID 和会话令牌后,您将把它们传递到 AWS.CognitoIdentityCredentials 提供商。这是一个例子:

AWS.config.credentials = new AWS.CognitoIdentityCredentials({   
    IdentityPoolId: 'IDENTITY_POOL_ID',    
    IdentityId: 'IDENTITY_ID_RETURNED_FROM_YOUR_PROVIDER',
    Logins: {
        'cognito-identity.amazonaws.com': 'TOKEN_RETURNED_FROM_YOUR_PROVIDER'    
    }
});
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到IDENTITY_ID_RETURNED_FROM_YOUR_PROVIDER,cognito-identity.amazonaws.comIDENTITY_ID_RETURNED_FROM_YOUR_PROVIDER? 我看到了如何做到这一点:

您可以通过调用 GetOpenIdTokenForDeveloperIdentity 来获取令牌。必须使用 AWS 开发人员凭证从后端调用此 API。

我检查了GetOpenIdTokenForDeveloperIdentity 文档并创建了这段代码:

const AWS = require('aws-sdk');
AWS.config.region = 'us-east-1'; // Region

const cognitoidentity = new AWS.CognitoIdentity(); …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-cognito aws-appsync

5
推荐指数
0
解决办法
918
查看次数

将所有 node_modules 路径传递给 AWS CodeBuild 缓存

目前我正在使用 AWS CodeBuild 来部署我的 monorepo 项目,并且我正在尝试使用它的缓存属性。我想缓存我的node_modules文件夹,我的buildspec.yml是:

version: 0.2

phases:
  install:
    commands:
      - echo Entered the install phase...
      - npm install
    finally:
      - echo This always runs even if the update or install command fails
  pre_build:
    commands:
      - echo Entered the pre_build phase...
    finally:
      - echo This always runs even if the login command fails
  build:
    commands:
      - echo Entered the build phase...
      - echo Build started on `date`
      - npm run build
    finally:
      - echo This …
Run Code Online (Sandbox Code Playgroud)

node.js monorepo aws-codebuild

5
推荐指数
0
解决办法
2886
查看次数

如何使用 Hostinger 域验证 AWS 证书?

我在使用 DNS 验证通过 Hostinger 域验证我的 AWS Certificate Manager 时遇到了麻烦。我已经按照适用于 GoDaddy 的 ACM遵循了GoDaddy 域的 DNS 验证中的提示。另外,我已经检查了证书请求问题疑难解答中列出的所有问题, 但也没有成功。有没有人有同样的问题?

谢谢!

更新 1:

我正在尝试使用DNS 验证作为验证方法来请求公共证书

更新 2 (17/05/19):

我遵循的步骤:

  1. 我在上午 8:52 创建了一个请求。
  2. 9:56 检查:

在此处输入图片说明

  1. 上午 9:59 向 DNS 提供商添加了 CNAME:

在此处输入图片说明

  1. 上午 10:49 检查状态:

在此处输入图片说明

dns cname amazon-web-services aws-certificate-manager

4
推荐指数
1
解决办法
1007
查看次数

Angular核心模块的作用是什么?

我读了一篇有关在Angular中组织文件夹的文章,作者使用了一个名为的文章core,其中他创建了核心模块并仅插入将被调用一次的服务。

目前,我正在一个项目上,因此我采用了本文推荐的结构。在core文件夹/模块内部,我创建了一个名为的模块api

\app
  \core
    \api
    ...
  \shared
  ...
Run Code Online (Sandbox Code Playgroud)

我的问题是:作为api模块,我想知道为什么不从中将其删除core并放在app文件夹中?

\app
  \api
  \core
  \shared
  ...
Run Code Online (Sandbox Code Playgroud)

角本身具有core模块太多(其中我们的进口ngModuleInjectable...),我想知道什么是它的作用。

directory-structure angular

2
推荐指数
1
解决办法
7961
查看次数

AWS AppSync GraphQL - 使用联合作为突变返回导致错误

我正在使用 AWS AppSync 创建一个 GraphQL 架构,我想Union用作突变返回。我想这样写突变:

mutation addUpdateTariff($tariff: TariffInput!, $seasonalTimeTariff: [SeasonalTimeTariffInput!]) {
  addUpdateTariff(tariff: $tariff, seasonalTimeTariff: $seasonalTimeTariff) {
    id
    type
    values {
      ... on SteppedTariff {
        endDate
      }
      ... on SeasonalTimeTariff {
        endDate
        peakConsumption
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

Request failed with status code 400
Run Code Online (Sandbox Code Playgroud)

该字段values可以是SteppedTariff或类型SeasonalTimeTariff,取决于addUpdateTariff突变的输入。据我搜索,Union仅用于查询,我没有找到一些说明它不能以不同方式使用的文档。

我错过了什么还是我真的不能用Union这种方式?

架构:

type Tariff {
  id: ID!
  type: TariffType!
  values: [TariffValue!]
}

type SteppedTariff {
  endDate: AWSDate
}

type SeasonalTimeTariff { …
Run Code Online (Sandbox Code Playgroud)

graphql aws-appsync

2
推荐指数
1
解决办法
908
查看次数

在模型类Angular中注入服务

假设我有一个服务,其中包含有关Angular应用程序中已记录用户的信息.我有一个名为的模型Sell,它包含一个id实例化某个Sell对象的用户的字段.有没有办法注入(我不知道" 注入 "是否是这里最好的词)模型中的用户服务以这种方式调用构造函数时,Sell会自动获取用户ID并将其分配给对象?

例:

user.service.ts

...
@Injectable()
export class UserService {
  private _id: string = 'some_id';

  get id(): string {
    return this._id;
  }    
}
Run Code Online (Sandbox Code Playgroud)

sell.model.ts

export class Sell {
  userId: string;
  price: number;
  ...

  constructor() {
    // some way to have userService here
    this.userId = this.userService.id;
  }
}
Run Code Online (Sandbox Code Playgroud)

some.component.ts

import { Component } from '@angular/core';
import { Sell } from '../models/sell.model';

@Component({
  ...
})
export class SomeComponent {

  newSell() {
    let sell = new …
Run Code Online (Sandbox Code Playgroud)

service dependency-injection typescript angular

1
推荐指数
1
解决办法
4407
查看次数

嵌套数组上的分页(属性)

我试图在社交网络的 nosql db 模型中遵循“一张表”原则。但它给我带来了很多问题。
假设我的模型现在看起来像这样:

Table-Groups
{
  name: "Group1"
  topics: [
    name: "Topic1"
    posts: [
      {
        id: "tid1"
        author: "Walter White"
        message: "Hello from Post1"
        comments: [
          {
            id: "cid1"
            author: "Jessy"
            message: "Yo nice post Mr. White"
          }
          {
            id: "cid2"
            author: "Saul"
            message: "Jeze Walt"
          }
        ]
      }
      //... Many other posts here    
    ]
      //... Many other topics within the group
  ]
}
//... Not so many other groups
Run Code Online (Sandbox Code Playgroud)

我可以对帖子或评论数组进行分页吗?
因为我会(理论上)在 post 数组中有很多帖子,所以我必须阅读大量数据,而实际上我只想阅读最新的 10 个帖子。帖子中的数组评论也是如此。有没有可能对这些数组进行分页?

我可以将主题数组中的属性“name”用作 sortKey 吗?(topic.name) …

amazon-web-services nosql amazon-dynamodb dynamodb-queries

1
推荐指数
1
解决办法
389
查看次数

防止AWS CloudFormation使用IAM删除DynamoDB

我正在尝试创建一个防止CloudFormation删除表的AWS角色。例如,我创建了如下表:

UsersDynamoDBTable:
    Type: AWS::DynamoDB::Table
    Description: Users DynamoDB Table
    Properties:
      AttributeDefinitions:
        - AttributeName: hashKey
          AttributeType: S
        - AttributeName: rangeKey
          AttributeType: S
      KeySchema:
        - AttributeName: hashKey
          KeyType: HASH
        - AttributeName: rangeKey
          KeyType: RANGE
      BillingMode: PAY_PER_REQUEST
      GlobalSecondaryIndexes:
        - IndexName: index-rangeKey
          KeySchema:
            - AttributeName: rangeKey
              KeyType: HASH
            - AttributeName: hashKey
              KeyType: RANGE
          Projection:
            ProjectionType: ALL
Run Code Online (Sandbox Code Playgroud)

现在,假设开发人员意外删除了这些行并更新了堆栈。这样,表及其所有数据将被删除。因此,我想创建一个防止CloudFormation删除DynamoDB表的角色。我的第一个尝试是在下面创建“角色”,但是没有用。

PreventCloudFormationDeleteTableIAMRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - cloudformation.amazonaws.com
            Action:
              - sts:AssumeRole
      Policies:
        - PolicyName: PreventTableDeletePolicy
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation amazon-iam aws-iam

0
推荐指数
1
解决办法
254
查看次数