小编Zha*_* Yi的帖子

如何在“serverless.yml”的“Resources”中使用“If”条件?

我尝试!If在部分中使用条件resources但失败了。我想控制是否设置provisionedConcurrency我的 lambda。lambda 在function节 下定义。


functions:
  getTransactionsHandler:
    ...

resources:
  Conditions:
    CommonPCNotZero: !Not [!Equals [0, '${self:custom.commonPC}']]
  Resources:
    !If 
      - CommonPCNotZero
      - getTransactionsHandler:
        Type: AWS::Lambda::Alias
          Properties:
            FunctionName: !Ref GetTransactionsHandlerLambdaFunction
            FunctionVersion: !Join ['', [!Ref GetTransactionsHandlerLambdaFunction, ':$LATEST']]
            ProvisionedConcurrencyConfig:
              ProvisionedConcurrentExecutions: '${self:custom.commonPC}'
      - !Ref AWS::NoValue
Run Code Online (Sandbox Code Playgroud)

运行时出现以下错误sls deploy

Error: The CloudFormation template is invalid: Template format error: [/Resources/Fn::If] resource definition is malformed
Run Code Online (Sandbox Code Playgroud)

使用条件的正确方法是什么!if

amazon-web-services aws-cloudformation aws-lambda serverless-framework

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

如何在预览视图图层上设置相机大小

我使用下面的代码在iPhone设备上显示相机.相机可以显示UI,我可以拍照.但是,相机仅显示在previewLayer的中间.如何让相机填满AVCaptureVideoPreviewLayer上的所有空间?我试图使用AVLayerVideoGravityResizeAspectFill引力,但它会使图像变形.

self.session = AVCaptureSession()
        do {
            let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
            try self.videoInput = AVCaptureDeviceInput(device: device)
        } catch {

        }
        if ((self.session?.canSetSessionPreset(AVCaptureSessionPresetHigh)) != nil){
            self.session?.sessionPreset = AVCaptureSessionPresetHigh
        }
        self.stillImageOutput = AVCaptureStillImageOutput()

        self.stillImageOutput?.outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG]
        if self.session!.canAddInput(self.videoInput){
            self.session?.addInput(self.videoInput)
        }
        if self.session!.canAddOutput(self.stillImageOutput){
            self.session?.addOutput(self.stillImageOutput)
        }

self.previewLayer = AVCaptureVideoPreviewLayer(session: self.session)
        //self.backView.frame = CGRectMake(0, 0, self.view.bounds.width,self.view.bounds.width)
        let viewLayer:CALayer = self.backView.layer
        viewLayer.masksToBounds = true
        let bounds:CGRect = viewLayer.bounds
        self.previewLayer?.frame = bounds
        self.previewLayer?.backgroundColor = UIColor.blackColor().CGColor
        self.previewLayer?.videoGravity = AVLayerVideoGravityResizeAspect//AVLayerVideoGravityResizeAspect
        self.backView.layer.addSublayer(self.previewLayer!)
Run Code Online (Sandbox Code Playgroud)

以下是相机的屏幕截图.

在此输入图像描述

ios swift

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

如何单击图像并进行旋转

我有以下reactjs代码.它渲染图像dom.我想实现一个羽毛,当用户点击该图像时,图像旋转180度.在旋转动画结束时,将其替换为新图像.我怎样才能在reactjs中实现它?

 <div>
  <img className="icon-arrow" src={icon} role="button" onClick={()=> { // create an animation to rotate the image }} />
</div>
Run Code Online (Sandbox Code Playgroud)

javascript css css3 reactjs

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

如何在Jenkins docker容器中切换到root?

我在Docker容器中设置了Jenkins服务器.我正在使用的图像是docker pull jenkins.之后我通过连接到容器docker exec -it b74d035352ec bash.默认用户是jenkins但我无法切换到root并获得以下错误:

jenkins@b74d035352ec:/$ su -
su: must be run from a terminal
Run Code Online (Sandbox Code Playgroud)

运行时出现以下错误sudo:

$ sudo ls

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?我确实需要该容器的root权限.或者我应该安装什么?如果需要,我可以从此图像构建新图像.

jenkins docker

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

为什么我在 vpc 中的 lambda 可以被 vpc 外部的 lambda 访问?

我在 AWS 中创建了一个 VPC。这是一个私有网络,互联网上的任何人都无法访问此 VPC。然后我将我的 lambda 放在这个 VPC 中。之后,我发现我可以从 外面的另一个 lambda 调用我的 lambda VPC。我还可以从我的本地笔记本电脑调用 lambda。

这是故意的吗?

amazon-web-services amazon-vpc aws-lambda

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

如何在 Dynamodb 中使用嵌套字段作为 TTL 字段?

我正在阅读https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html以在 Dynamodb 表上添加 TTL 字段。但我找不到它如何支持嵌套字段作为 TTL 字段。例如,

id: xxx
user: { firstName: '', lastName:'', age: ''}
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,我如何使用user -> age作为 ttl 字段?

amazon-web-services amazon-dynamodb

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