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

delete hosted config version when deleting appconfig profile #308

Open
wants to merge 6 commits into
base: figma
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
93 changes: 45 additions & 48 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,51 @@
name: Post Publish
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
release:
types: [published]
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
tidy:
name: Tidy Asana
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: breathingdust/github-asana-tidy@v1
-
name: Checkout
uses: actions/[email protected]
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
asana_pat: ${{ secrets.asana_pat }}
asana_target_section_gid: '1141945723817371'
asana_workspace_gid: '90955849329269'
asana_project_gid: '632425409545160'
asana_github_url_field_gid: '1134594824474912'
github_release_name: ${{ github.event.release.tag_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
project-archive:
name: Archive Released Cards
runs-on: ubuntu-latest
steps:
- uses: breathingdust/github-project-archive@v1
go-version: 1.16
-
name: Import GPG key
id: import_gpg
uses: hashicorp/[email protected]
env:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/[email protected]
with:
github_done_column_id: 11513756
github_release_name: ${{ github.event.release.tag_name }}
github_token: ${{ secrets.ORGSCOPED_GITHUB_TOKEN }}
changelog-newversion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
- run: |
CHANGELOG_FILE_NAME="CHANGELOG.md"
PREVIOUS_RELEASE_TAG=$(git describe --abbrev=0 --match='v*.*.*' --tags)
echo Previous release is: $PREVIOUS_RELEASE_TAG

NEW_RELEASE_LINE=$(echo $PREVIOUS_RELEASE_TAG | awk -F. '{
$1 = substr($1,2)
$2 += 1
printf("%s.%02d.%s\n\n", $1, $2, $3);
}')

echo New minor version is: v$NEW_RELEASE_LINE

echo -e "## $NEW_RELEASE_LINE (Unreleased)\n$(cat $CHANGELOG_FILE_NAME)" > $CHANGELOG_FILE_NAME
- run: |
git config --local user.email [email protected]
git config --local user.name changelogbot
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md after ${{ github.event.release.tag_name }}"
git push
version: latest
args: release --rm-dist --timeout 60m
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69 changes: 38 additions & 31 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
archives:
- files:
- none*
format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
- go mod download
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- binary: '{{ .ProjectName }}_{{ .Version }}'
flags:
- -trimpath
goarch:
- '386'
- amd64
- arm
- arm64
goos:
- darwin
- freebsd
- linux
- windows
ignore:
- goarch: '386'
goos: darwin
ldflags:
- -s -w -X version.ProviderVersion={{.Version}}
mod_timestamp: '{{ .CommitTimestamp }}'
changelog:
skip: true
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
env:
- CGO_ENABLED=0
release:
disable: true
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
1 change: 1 addition & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ func Provider() *schema.Provider {
"aws_ecs_cluster": resourceAwsEcsCluster(),
"aws_ecs_service": resourceAwsEcsService(),
"aws_ecs_task_definition": resourceAwsEcsTaskDefinition(),
"aws_ecs_task_set": resourceAwsEcsTaskSet(),
"aws_efs_access_point": resourceAwsEfsAccessPoint(),
"aws_efs_backup_policy": resourceAwsEfsBackupPolicy(),
"aws_efs_file_system": resourceAwsEfsFileSystem(),
Expand Down
36 changes: 36 additions & 0 deletions aws/resource_aws_appconfig_configuration_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,42 @@ func resourceAwsAppconfigConfigurationProfileDelete(d *schema.ResourceData, meta
return err
}

// It is required for us to delete all of the Hosted Configuration Versions before deleting the Configuration Profile
// At Figma, we don't track all of the created Hosted Configuration Versions, so need a method outside our terraform
// configs to perform this operation
nextToken := aws.String("1")

for {
cvInput := &appconfig.ListHostedConfigurationVersionsInput{
ApplicationId: aws.String(appID),
ConfigurationProfileId: aws.String(confProfID),
nextToken: nextToken,
}
cvOutput, err := conn.ListHostedConfigurationVersions(cvInput)

if err != nil {
return err
}

for _, confVersion := range cvOutput.Items {
deleteCVInput := &appconfig.DeleteConfigurationProfileInput{
ApplicationId: aws.String(appID),
ConfigurationProfileId: aws.String(confProfID),
VersionNumber: confVersion.VersionNumber
}
_, err := conn.DeleteHostedConfigurationVersion(deleteCVInput)
if (err != nil) {
return err
}
}

if (cvOutput.NextToken == nil) {
break
}

nextToken = cvOutput.NextToken
}

input := &appconfig.DeleteConfigurationProfileInput{
ApplicationId: aws.String(appID),
ConfigurationProfileId: aws.String(confProfID),
Expand Down
6 changes: 4 additions & 2 deletions aws/resource_aws_ecs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,10 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[ERR] Error setting placement_constraints for (%s): %s", d.Id(), err)
}

if err := d.Set("network_configuration", flattenEcsNetworkConfiguration(service.NetworkConfiguration)); err != nil {
return fmt.Errorf("error setting network_configuration for (%s): %w", d.Id(), err)
if service.DeploymentController == nil || aws.StringValue(service.DeploymentController.Type) != ecs.DeploymentControllerTypeExternal {
if err := d.Set("network_configuration", flattenEcsNetworkConfiguration(service.NetworkConfiguration)); err != nil {
return fmt.Errorf("error setting network_configuration for (%s): %w", d.Id(), err)
}
}

if err := d.Set("service_registries", flattenServiceRegistries(service.ServiceRegistries)); err != nil {
Expand Down
Loading