Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parametrise requires_session #11

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Contribution guidelines
We're happy to accept 3rd-party contributions. Please make sure you read this document before you do any work though, as we have some expectations related to the content and quality of change sets.

Page flows and content are created and changed depending on our findings and ideas, which are unfortunately not available unless you are working for the HMCTS Reform programme.

Before contributing
Because of the above, any ideas on the user journeys and general service experience you may have should be first consulted with us by submitting a new issue to this repository. Ideas are always welcome, but if something is divergent or unrelated to what we're trying to achieve we won't be able to accept it. Please keep this in mind as we don't want to waste anybody's time.

In the interest of creating a friendly collaboration environment, please read and adhere to an open source contributor's code of conduct.

Making a contribution
After your idea has been accepted you can implement it. We don't allow direct changes to the codebase from the public, they have to go through a review first.

Here's what you should do:

fork this repository and clone it to your machine,
create a new branch for your change:
use the latest master to branch from,
implement the change in your branch:
if the change is non-trivial it's a good practice to split it into several logically independent units and deliver each one as a separate commit,
make sure the commit messages use proper language and accurately describe commit's content, e.g. "Unify postcode lookup elements spacing". More information on good commit messages can be found here,
test if your feature works as expected and does not break any existing features,
push the change to your GitHub fork,
submit a pull request to our repository:
ensure that the pull request and related GitHub issue reference each other.
At this point the pull request will wait for someone from our team to review. It may be accepted straight away, or we may ask you to make some additional amendments before incorporating it into the main branch.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
What would you like to change?
How do you think that would improve the project?
If this entry is related to a bug, please provide the steps to reproduce it
3 changes: 3 additions & 0 deletions .github/PULLREQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Resolves # . (This is applicable only if this pull request relates to a GitHub issue, delete the line otherwise)

Notes: * * *
39 changes: 39 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Terraform'

on:
pull_request:
branches:
- master

env:
TF_VERSION: 0.12.29

jobs:
terraform:
name: 'terraform'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ env.TF_VERSION }}

- name: Setup providers configuration
shell: bash
run: |
cat << EOF > provider.tf
provider "azurerm" {
features {}
}
EOF
- name: Terraform Init
run: terraform init

- name: Terraform format
run: terraform fmt -check

- name: Terraform validate
run: terraform validate
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# terraform-module-servicebus-subscription

A Terraform module for creating Azure Service Bus subscription
Refer to the following link for a detailed explanation of the Azure Service Bus topic.

[Azure Service Bus Subscription](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-queues-topics-subscriptions) <br />

## Usage

The following example shows how to use the module to create an Azure Service Bus topic.

```terraform
module "servicebus-subscription" {
source = "[email protected]:hmcts/terraform-module-servicebus-subscription?ref=servicebus_subscription_tf"
name = local.subscription_name
namespace_name = module.servicebus-namespace.name
topic_name = module.servicebus-topic.name
resource_group_name = local.resource_group_name
}
```

## Variables

### Configuration

The following parameters are required by this module

- `name` the name of the ServiceBus namespace.
- `resource_group_name` the name of the resource group in which to create the ServiceBus namespace.
- `namespace_name` the name of the service bus namespace in which the topic must be created.
- `topic_name` the name of the service bus topic in which the subscription must be created.

The following parameters are optional

- `max_delivery_count` the maximum number of deliveries. Default is 10.
- `lock_duration` the lock duration for the subscription as an ISO 8601 duration. Default is PT1M.
- `forward_to` the name of a Queue or Topic to automatically forward messages to.
- `forward_dead_lettered_messages_to` the name of a Queue or Topic to automatically forward Dead Letter messages to.
34 changes: 15 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# ARM template for Service Bus subscription
data "template_file" "subscription_template" {
template = "${file("${path.module}/template/subscription_template.json")}"
}
resource "azurerm_servicebus_subscription" "servicebus_subscription" {
name = var.name
resource_group_name = var.resource_group_name
namespace_name = var.namespace_name
topic_name = var.topic_name

# Create Azure Service Bus subscription
resource "azurerm_template_deployment" "subscription" {
template_body = "${data.template_file.subscription_template.rendered}"
name = "${var.name}"
deployment_mode = "Incremental"
resource_group_name = "${var.resource_group_name}"
lock_duration = var.lock_duration
max_delivery_count = var.max_delivery_count
forward_to = var.forward_to
forward_dead_lettered_messages_to = var.forward_dead_lettered_messages_to
requiresSession = var.requires_session

parameters = {
serviceBusNamespaceName = "${var.namespace_name}"
serviceBusTopicName = "${var.topic_name}"
serviceBusSubscriptionName = "${var.name}"
lockDuration = "${var.lock_duration}"
maxDeliveryCount = "${var.max_delivery_count}"
forwardTo = "${var.forward_to}"
forwardDeadLetteredMessagesTo = "${var.forward_dead_lettered_messages_to}"
}
requires_session = var.requires_session
dead_lettering_on_message_expiration = true
enable_batched_operations = false
default_message_ttl = "P10675199DT2H48M5.4775807S"
auto_delete_on_idle = "P10675199DT2H48M5.4775807S"
}
69 changes: 0 additions & 69 deletions template/subscription_template.json

This file was deleted.

32 changes: 19 additions & 13 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
variable "name" {
type = "string"
type = string
description = "Azure Service Bus subscription name"
}

variable "namespace_name" {
type = "string"
type = string
description = "Azure Service Bus namespace"
}

variable "topic_name" {
type = "string"
type = string
description = "Azure Service Bus topic name"
}

variable "resource_group_name" {
type = "string"
type = string
description = "Resource group in which the Service Bus subscription should exist"
}

variable "max_delivery_count" {
type = "string"
type = number
description = "Maximum number of attempts to deliver a message before it's sent to dead letter queue"
default = "10"
default = 10
}

variable "lock_duration" {
type = "string"
type = string
description = "Message lock duration (ISO-8601)"
default = "PT1M"
default = "PT1M"
}

variable "forward_to" {
type = "string"
type = string
description = "Topic or Queue to forwards received messages to"
default = ""
default = ""
}

variable "forward_dead_lettered_messages_to" {
type = "string"
type = string
description = "Topic or Queue to forwards dead lettered messages to"
default = ""
}
default = ""
}

variable "requires_session" {
type = bool
description = "A value that indicates whether the queue supports the concept of sessions"
default = false
}