Skip to content

Commit

Permalink
Ensure correct property is autonamed in Sqs Fifo Queues (#1398)
Browse files Browse the repository at this point in the history
Fixes: #967

```
▶ pulumi up
.....
     Type                 Name                  Status
 +   pulumi:pulumi:Stack  testing-aws-fifo-dev  created
 +   └─ aws:sqs:Queue     main2                 created

Outputs:
    name: "main2-801295a.fifo"

Resources:
    + 2 created

Duration: 8s
```
  • Loading branch information
stack72 authored Mar 13, 2021
1 parent b03b081 commit c8b7720
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 1 deletion.
14 changes: 14 additions & 0 deletions examples/examples_dotnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/pulumi/pulumi/pkg/v2/testing/integration"
"github.com/stretchr/testify/assert"
)

func TestAccWebserverCs(t *testing.T) {
Expand All @@ -20,6 +21,19 @@ func TestAccWebserverCs(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestAccFifoSqsQueueCs(t *testing.T) {
test := getCSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "sqs-fifo-queue", "csharp"),
RunUpdateTest: false,
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
assert.Contains(t, stack.Outputs["QueueName"].(string), ".fifo")
},
})

integration.ProgramTest(t, &test)
}

func getCSBaseOptions(t *testing.T) integration.ProgramTestOptions {
envRegion := getEnvRegion(t)
base := getBaseOptions()
Expand Down
13 changes: 13 additions & 0 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,19 @@ func TestAccMultipleRegions(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestAccFifoSqsQueueTs(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "sqs-fifo-queue", "ts"),
RunUpdateTest: false,
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
assert.Contains(t, stack.Outputs["name"].(string), ".fifo")
},
})

integration.ProgramTest(t, &test)
}

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
envRegion := getEnvRegion(t)
base := getBaseOptions()
Expand Down
14 changes: 14 additions & 0 deletions examples/examples_py_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/pulumi/pulumi/pkg/v2/testing/integration"
"github.com/stretchr/testify/assert"
)

func TestAccBucketPy(t *testing.T) {
Expand Down Expand Up @@ -86,6 +87,19 @@ func TestAccCodeBuildProjectPy(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestAccFifoSqsQueuePy(t *testing.T) {
test := getPythonBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "sqs-fifo-queue", "python"),
RunUpdateTest: false,
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
assert.Contains(t, stack.Outputs["name"].(string), ".fifo")
},
})

integration.ProgramTest(t, &test)
}

func getPythonBaseOptions(t *testing.T) integration.ProgramTestOptions {
envRegion := getEnvRegion(t)
base := getBaseOptions()
Expand Down
19 changes: 19 additions & 0 deletions examples/sqs-fifo-queue/csharp/MyStack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Pulumi;
using Pulumi.Aws.Sqs;

class MyStack : Stack
{
public MyStack()
{
var queue = new Queue("demo", new QueueArgs
{
FifoQueue = true,
});

// Export the name of the queue to allow us to check for ".fifo" name
this.QueueName = queue.Name;
}

[Output]
public Output<string> QueueName { get; set; }
}
7 changes: 7 additions & 0 deletions examples/sqs-fifo-queue/csharp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Threading.Tasks;
using Pulumi;

class Program
{
static Task<int> Main() => Deployment.RunAsync<MyStack>();
}
3 changes: 3 additions & 0 deletions examples/sqs-fifo-queue/csharp/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: testing-aws-fifo-dotnet
runtime: dotnet
description: A simple example of using autonaming Fifo queues in CSharp
9 changes: 9 additions & 0 deletions examples/sqs-fifo-queue/csharp/testing-aws-fifo-dotnet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions examples/sqs-fifo-queue/python/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: testing-aws-fifo-dotnet
runtime: python
description: A simple example of using autonaming Fifo queues in python
9 changes: 9 additions & 0 deletions examples/sqs-fifo-queue/python/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2016-2020, Pulumi Corporation. All rights reserved.

import pulumi
from pulumi_aws import sqs

queue = sqs.Queue('demo',
fifo_queue=True)

pulumi.export('name', queue.name)
2 changes: 2 additions & 0 deletions examples/sqs-fifo-queue/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=2.0.0,<3.0.0
pulumi_aws>=3.0.0,<4.0.0
3 changes: 3 additions & 0 deletions examples/sqs-fifo-queue/ts/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: testing-aws-fifo-ts
runtime: nodejs
description: A simple example of using autonaming Fifo queues in TypeScript
25 changes: 25 additions & 0 deletions examples/sqs-fifo-queue/ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2016-2018, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const config = new pulumi.Config("aws");
const providerOpts = { provider: new aws.Provider("prov", { region: <aws.Region>config.require("envRegion") }) };

const queue = new aws.sqs.Queue("demo", {
fifoQueue: true,
}, providerOpts);

export const name = queue.name;
18 changes: 18 additions & 0 deletions examples/sqs-fifo-queue/ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "sqs-fifo-queue-typescript",
"version": "0.0.1",
"license": "Apache-2.0",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@pulumi/pulumi": "^2.0.0",
"@pulumi/aws": "^3.0.0"
},
"devDependencies": {
"@types/aws-sdk": "^2.7.0",
"@types/node": "^8.0.0"
}
}
18 changes: 18 additions & 0 deletions examples/sqs-fifo-queue/ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.ts"
]
}
2 changes: 1 addition & 1 deletion provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ func Provider() tfbridge.ProviderInfo {
Randlen: 7,
// If this is a FIFO Queue, it's name must end with `.fifo`
PostTransform: func(res *tfbridge.PulumiResource, name string) (string, error) {
if fifo, hasfifo := res.Properties["fifo"]; hasfifo {
if fifo, hasfifo := res.Properties["fifoQueue"]; hasfifo {
if fifo.IsBool() && fifo.BoolValue() {
return name + ".fifo", nil
}
Expand Down

0 comments on commit c8b7720

Please sign in to comment.