小编Ada*_*dam的帖子

REST API 的 CloudFormation 堆栈错误不包含任何方法

部署 CloudFormation 堆栈时获取以下信息:

REST API 不包含任何方法(服务:AmazonApiGateway;状态代码:400;错误代码:BadRequestException;请求 ID:d527f56e-a1e1-11e9-a0a4-af7563b2b15a)

该堆栈具有由具有单个资源和方法的 API 触发的单个 Lambda:

FailureReporting:
    Type: "AWS::ApiGateway::RestApi"
    DependsOn: "MyLambdaFunction"
    Properties:
      Name: "FailureReporting"
      FailOnWarnings: true
  FailureReportingDeployment:
    Type: AWS::ApiGateway::Deployment
    Properties:
      RestApiId:
        Ref: "FailureReporting"
      Description: "Production environment supporting version-1 of the interface."
      StageName: "v1"
  Failures:
    Type: "AWS::ApiGateway::Resource"
    Properties:
      RestApiId: !Ref "FailureReporting"
      ParentId: !GetAtt ["FailureReporting", "RootResourceId"]
      PathPart: "failures"
  FailuresMethodGet:
    Type: "AWS::ApiGateway::Method"
    Properties:
      RestApiId: !Ref "FailureReporting"
      ResourceId: !Ref "Failures"
      HttpMethod: "GET"
      AuthorizationType: "NONE"
      MethodResponses:
        - StatusCode: "200"
      Integration:
        IntegrationHttpMethod: "POST"
        Type: "AWS_PROXY"
        IntegrationResponses:
          - StatusCode: "200"
        Credentials: !GetAtt …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation

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

手动触发 AWS CloudWatch 事件

我在 CloudWatch 中有一个事件,每天触发一次。有没有办法手动触发事件(用于测试目的)?

...我意识到我可以增加事件触发计划的频率。

amazon-web-services amazon-cloudwatch

10
推荐指数
3
解决办法
8339
查看次数

从内部模拟脚本块访问外部变量(Pester)

假设我有一个类似的功能...

function Get-Something {
  return Get-DogShit
}
Run Code Online (Sandbox Code Playgroud)

...在我的 Pester 测试脚本中...

$var = 1

Mock 'Get-Dogshit' { return $var }

it 'should return true' {
  Get-Something | should $var
}
Run Code Online (Sandbox Code Playgroud)

这行不通,但是你明白我在这里想做什么吗?我想将局部变量的值获取到 MOCK 脚本块中。我想避免对模拟中的返回值和 it 块中的预期结果进行硬编码。关于如何实现这一目标有什么想法吗?

powershell pester

8
推荐指数
2
解决办法
1362
查看次数

重命名 CloudFormation 模板中的资源

您可以重命名 CloudFormation 模板中的资源吗?

假设我创建了一个堆栈模板来创建单个 lambda 函数。

GetTheFunnyPhraseText:
  Type: AWS::Serverless::Function
  Properties:
    CodeUri: ../Lambda/
    Handler: GetFunnyPhrase.handler
    FunctionName: GetFunnyPhrase
    Role: !GetAtt [ ExecuteFunctionGetFunnyPhrase, Arn ]
Run Code Online (Sandbox Code Playgroud)

无论出于何种原因,我想将资源名称更改GetTheFunnyPhraseTextGetFunnyPhrase. 是否有更改名称的机制?

我尝试了几件事...

  • 更改模板中的资源名称。看起来这就像删除GetTheFunnyPhraseText和创建GetFunnyPhrase. 这里的问题是资源创建发生在资源删除之前,导致操作失败,因为 Lambda 函数存在。
  • 创建模板的两个草稿。Draft-1:更改现有资源的函数名称。Draft-2:删除旧资源(从模板中省略它们的定义)并添加新资源。按顺序执行草稿模板:第一个然后第二个。这有效。这太恶心了。

对于那些建议不要命名函数的人,理解;暂时在该反馈中放置一个引脚。

amazon-web-services aws-cloudformation

7
推荐指数
2
解决办法
4066
查看次数

在本地环境中调用 getResolvedOptions() 会生成 KeyError

我有一个本地 AWS Glue 环境,其中包含 AWS Glue 库、Spark、PySpark 以及安装的所有内容。

我正在运行以下代码(实际上是在 REPL 中复制粘贴):

from awsglue.utils import getResolvedOptions

args = []
args.insert(-1, {"--JOB_NAME": "JOB_NAME"})
args.insert(-1, {"--input_file_path": "s3://things/that.csv"})
args.insert(-1, {"--output_bucket": "s3://things"})

getResolvedOptions(args, [
    '--JOB_NAME',
    '--input_file_path',
    '--output_bucket']
)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "C:\Users\UBI9\bin\aws-glue-libs\PyGlue.zip\awsglue\utils.py", line 115, in getResolvedOptions
  File "C:\Progra~1\Python37\lib\argparse.py", line 1781, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "C:\Progra~1\Python37\lib\argparse.py", line 1822, in _parse_known_args
    option_tuple = self._parse_optional(arg_string)
  File "C:\Progra~1\Python37\lib\argparse.py", line 2108, in _parse_optional
    if not arg_string[0] …
Run Code Online (Sandbox Code Playgroud)

python traceback aws-glue

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

无法跳过 Jenkins Build by SCM Skip Plugin

我正在 Jenkins 中编写一个管道脚本,以根据提交消息构建项目。从Jenkins的论坛,我注意到我们可以使用SCM跳过插件。我安装了该插件并按照论坛的建议添加了以下阶段:

scmSkip(deleteBuild: true, skipPattern:'.*\\[ci skip\\].*')
Run Code Online (Sandbox Code Playgroud)

当我使用以下提交消息提交更改时:

git commit -m "[ci skip] Updated Audit Test Data Files with scan status"
Run Code Online (Sandbox Code Playgroud)

不会跳过构建。它与其他阶段一起进展。

在控制台日志中,我看到消息

SCM 跳过:更改日志为空!

当发现包含“[ci Skip]”的提交消息时,如何构建 scmSkip 调用以跳过构建?是否有更容易实施的替代方案?

谢谢,卡蒂克·P。

jenkins jenkins-plugins jenkins-cli jenkins-groovy jenkins-pipeline

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

从函数/脚本返回 ArrayList

鉴于以下脚本:

function f {
    [CmdletBinding()]Param()
    Write-Verbose 'f: Start'
    $t = New-Object 'System.Collections.ArrayList'
    Write-Verbose $t.GetType().Name
    return $t
}

$things = New-Object 'System.Collections.ArrayList'
$things.GetType().Name
$things = f -verbose
$things.GetType().Name
Run Code Online (Sandbox Code Playgroud)

为什么最后一行中的$thingsbe-of-type不会ArrayList

powershell

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

CloudFormation 模板中的 Lambda 资源将 CodeUri 报告为无效

鉴于以下 CloudFormation 模板片段:

AWSTemplateFormatVersion: 2010-09-09
Resources:
  PrototypeCreateOrderFDM4:
    Type: "AWS::Lambda::Function"
    Properties:
      CodeUri: "../Lambda/"
      Handler: "PrototypeCreateOrder.handler"
      Timeout: 15
      Runtime: "nodejs10.x"
      Role: arn:aws:iam::123456789012:role/deezNutz-Role-1ABC8DDEFGHI
Run Code Online (Sandbox Code Playgroud)

我收到一条警告说 CodeURI 不是一个有效的属性:

在此处输入图片说明

我有很多像这样的其他 Lambda 结构。我以前从来没有得到过这个。我错过了什么?

amazon-web-services aws-cloudformation

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

通过 Powershell 为证书的私钥分配权限(Win 2012 R2)

在连接到域的 Windows Server 2012 R2 机器上,我正在运行以下语句:

$target_machine_fqdn = [System.Net.Dns]::GetHostByName($env:computerName)

$certificate_request = Get-Certificate `
    -Template 'AcmeComputer' `
    -DnsName $target_machine_fqdn `
    -CertStoreLocation 'Cert:\LocalMachine\My'
Run Code Online (Sandbox Code Playgroud)

我正在向域的 CA 请求主机证书。该语句返回没有错误。为机器生成证书并根据要求将其放置在“Cert:\LocalMachine\My”中。

问题:我不知道如何向服务帐户授予证书私钥的权限。

现在,大约有 1,000篇文章通过检索UniqueKeyContainerName以如下开头的代码来指导人们如何授予权限:

$certificate.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
Run Code Online (Sandbox Code Playgroud)

这在这里行不通。虽然证书有私钥,但私钥数据成员为空:

在此处输入图片说明

在我刚刚逃避的解决方案有效的情况下,私钥在文件系统上。但是,在这种情况下,私钥位于以下注册表中:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\MY\Keys
Run Code Online (Sandbox Code Playgroud)

使用证书 MMC-snapin 时,我可以看到证书。我可以管理私钥的权限。所以,我知道它在那里。不幸的是,我需要自动分配权限,因此不能选择使用证书 MMC-snapin。我需要通过 Powershell 以某种方式执行此操作。

windows powershell cryptography x509certificate

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

在 AWS 中分离环境

是否有关于在 AWS 中分离环境的最佳实践?

我有一个使用以下服务的解决方案:

  • 拉姆达
  • 社交网络
  • 质量标准
  • 动态数据库
  • API网关
  • S3
  • 我是

我们还没有生活,但我们已经接近了。到我们上线时,我想要一个适当的生产、测试​​和开发环境,它们之间有“合理”的隔离度。

  1. 每个环境的单独帐户
  2. 每个环境的单个账户和单独的 VPC

我阅读了Charity Majors的文章AWS 网络、环境和你。我对通过 VPC 进行分段感到失望,但我不知道我的堆栈中的所有服务都是 VPC 范围的?以下是我的一些要求:

  • 限制服务名称冲突(针对非全局服务)
  • 在环境之间建立非常清晰的界限
  • 最后,在环境级别授予权限

我正在使用 AWS 组织。

PS 抱歉,如果这不是问题的正确论坛。如果有更好的东西,请告诉我,我会移动它。

amazon-web-services amazon-sns amazon-dynamodb aws-lambda

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