Skip to content

feat: Support "import" command#38

Merged
anisaoshafi merged 2 commits intolocalstack:mainfrom
kakakakakku:support-import
Oct 23, 2025
Merged

feat: Support "import" command#38
anisaoshafi merged 2 commits intolocalstack:mainfrom
kakakakakku:support-import

Conversation

@kakakakakku
Copy link
Contributor

Hi😀 Thanks for the useful tools.

When I tried pulumilocal, I found that the import command is not supported. There is use case where I want to import LocalStack resources with pulumilocal. This pull request adds support for the import command.

Check

At first, I created a CloudWatch Logs Group in LocalStack using AWS CLI.

$ awslocal logs create-log-group --log-group-name my-log-group
$ awslocal logs describe-log-groups --log-group-name-prefix my-log-group
{
    "logGroups": [
        {
            "logGroupName": "my-log-group",
            "creationTime": 1759278603452,
            "metricFilterCount": 0,
            "arn": "arn:aws:logs:ap-northeast-1:000000000000:log-group:my-log-group:*",
            "storedBytes": 0
        }
    ]
}

After that, with the pulumilocal that supports the import command, I was able to import the CloudWatch Logs Group successfully.

$ python ~/ghq/github.com/kakakakakku/pulumi-local/bin/pulumilocal import aws:cloudwatch/logGroup:LogGroup my-log-group my-log-group
Config strategy: None
Config strategy is not recognised. Falling back to default ("overwrite").
Stack config file ./Pulumi.local.yaml already exists. File will be overwritten.
	Only 'yes' will be accepted to approve.
	Enter a value: yes
Updating this Stack with LocalStack config
Previewing import (local)

(snip)

     Type                        Name                        Plan
     pulumi:pulumi:Stack         test-for-pulumilocal-local
 =   └─ aws:cloudwatch:LogGroup  my-log-group                import

Resources:
    = 1 to import
    1 unchanged

Do you want to perform this import? yes
Importing (local)

(snip)

     Type                        Name                        Status
     pulumi:pulumi:Stack         test-for-pulumilocal-local
 =   └─ aws:cloudwatch:LogGroup  my-log-group                imported (3s)

Resources:
    = 1 imported
    1 unchanged

Duration: 7s

Please copy the following code into your Pulumi application. Not doing so
will cause Pulumi to report that an update will happen on the next update command.

Please note that the imported resources are marked as protected. To destroy them
you will need to remove the `protect` option and run `pulumi update` *before*
the destroy will take effect.

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

const my_log_group = new aws.cloudwatch.LogGroup("my-log-group", {
    name: "my-log-group",
    region: "ap-northeast-1",
}, {
    protect: true,
});

Thank you!

@kakakakakku
Copy link
Contributor Author

Can someone please give a review?
Thanks😀

Increment version and add change log
Copy link

@anisaoshafi anisaoshafi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kakakakakku.
Thanks a lot for your patience and adding this great contribution 👏🏼
I've tested your PR and LGTM 🚀

FYI: Added a commit that bumps version to 1.31 and adds a change log so we can later push it to PyPI.

@anisaoshafi anisaoshafi merged commit c8eea84 into localstack:main Oct 23, 2025
1 check passed
@kakakakakku kakakakakku deleted the support-import branch October 23, 2025 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants